Brian, This is incredibly useful info and could be helpful to add to the official documentation.
Similar to the play_hosts variable, is there something like a "play_roles" variable that is an ordered list of roles for the current play? I'd like to be able to trigger certain behavior (restarts and such) based on the presence or absence of particular roles in that list. On Friday, September 4, 2015 at 9:51:32 AM UTC-7, Brian Coca wrote: > > You seem to want the play_hosts variable (current active hosts in current > play). > > On Fri, Sep 4, 2015 at 12:44 PM, James Morgan <[email protected] > <javascript:>> wrote: > > Ok thanks, > > > > I think I will need to pass it through from the playbook, the issue is > that > > on a flat deployment where every group has the same host, when I use > > group_names I get all possible groups, not the one currently being > handled. > > > > This meant that I ended up with a duplicate list of about 12 hosts. Is > it > > possible to append to a list in jinja. If so I could loop over > groups_names, > > then over the hosts in that group and build up a list of hosts then uniq > the > > list > > > > {% for group in group_names %} > > {% for host in groups[group] %} > > .... > > > > > > <Location /admin> > > SetHandler otas-handler > > > > OTASHost 172.31.5.20 19202 > > > > OTASHost 172.31.5.20 19202 > > > > OTASHost 172.31.5.20 19202 > > > > OTASHost 172.31.5.20 19202 > > ..... > > > > Thanks for the consise list of the others, very useful. > > > > On Friday, 4 September 2015 16:46:12 UTC+1, Brian Coca wrote: > >> > >> current_host = inventory_hostname > >> current_group = no singular, we always flatten to host, you can check > >> the current host's groups in "group_names" list of the current host > >> current_user = lookup('env', 'USER') ? > >> current_task = nothing represents the current task .. since you are in > >> the current task ..., not sure what you want here. > >> current_role = role_path|basename > >> > >> > >> -- > >> Brian Coca > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Ansible Project" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/ansible-project/9aaf2756-36e6-43f1-bb5a-a8b6d6a1c076%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Brian Coca > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a0a81602-d4b9-4765-bb80-45970f7bd3e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
