awesome !! didn't you know you could reference it directly .. thanks for the info and speedy reply -- will give it a try here in a bit ..
greg On Thu, Jan 9, 2014 at 1:31 PM, Matt Martz <[email protected]> wrote: > I think what you probably want is something like: > > #inventory > [db_slave] > host1 > host2 > > > #playbook > - name: create slave user for each slave host > mysql_user: > name=slave > password=foo > host={{ hostvars[item]['ansible_hostname'] }} > state=present > with_items: groups['db_slave'] > > No need to create another variable anywhere. And I used ansible_hostname > here, since hostname is not a standard var and I wasn't sure if that is a > custom var you have set for those hosts. > -- > Matt Martz > [email protected] > > On January 9, 2014 at 12:07:33 PM, Gregory Spranger ([email protected]) > wrote: > > hi all, > > i am trying to be DRY, and wondering if i can somehow register all of the > hosts that are part of inventory group .. for example: > > #inventory > [db_slave] > host1 > host2 > > > #playbook > - name: create slave user for each slave host > mysql_user: > name=slave > password=foo > host={{ item }} > state=present > with_items: > - #need help here > - #somehow get list of hosts from group db_slave > > yes, i did see this example online: > > {% for host in groups['db_slave'] %} > {{ hostvars[host]['hostname'] }} > {% endfor %} > > and i even tried to put that into my roles "vars" directory .. but just kept > getting syntax errors which makes sense .. > > # slave hosts > mysql_slave_hosts: > {% for host in groups['db_slave'] %} > - {{ hostvars[host]['hostname'] }} > {% endfor %} > > > any thoughts ?? > > > thanks as always, > greg > > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
