You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Hi all, I hope somebody can offer me a little guidance. I've read a decent amount on jinja2 and as I'm still learning python; so with that I hoped for a little guidance.
Essentially I want to apply a role based off an item in the hostname.
So {{ ansible_hostname }} = las01-123-984 where 123 is the host type. That's my role that's setup. It sets up the box as an apache system with new firewall and all that.
I've just been unable to get the proper parser to pull the 123 from the hostname.
Any guidance would be fantastic, thank you all!!
James Martin
unread,
Sep 22, 2014, 9:07:23 AM9/22/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
I believe you'd want to use an inventory pattern here:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
The regex_replace filter is probably what you're looking for. Assuming
there are only ever 3 segments separated by a hyphen, and you want the
2nd, something like this would work:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
I'd vote for James Martin's suggestion for selecting hosts based on the pattern.
The other vote is good enough for getting out the string and putting it into a conditional, but using the pattern construct is more readable and also produces cleaner output.