How can I use this *when* function to work with the hosts in my inventory file? I had *when: inventory_hostname == play_hosts[0]* but I notice that it only selects a random server. I want it to select all of the servers. Using a * doesn't work..
On Monday, December 2, 2013 at 12:03:27 AM UTC-6, benno joy wrote: > > Hi David, > > > That means the first host in the group "mongo_Servers". [0] notion means > the first element in a list. similarly [1] means the second element in a > list. > > > Regards, > Benno > > > > On Sun, Dec 1, 2013 at 12:20 PM, David Coronel <[email protected] > <javascript:>> wrote: > >> I saw this in the ansible-examples / openshift / openshift_ec2 / roles / >> mongodb / tasks / main.yml >> >> - name: Initialize the replication set >> shell: /usr/bin/mongo --port "{{ mongod_port }}" >> /tmp/repset_init.js;touch /opt/rep.init creates=/opt/rep.init >> when: inventory_hostname == groups['mongo_servers'][0] >> >> >> What does the [0] mean in when: inventory_hostname == >> groups['mongo_servers'][0] ? >> >> I wanted to find a conditional that would say: when inventory_hostname >> is not in group mailservers >> >> It seems to work for me with this now: >> >> when: inventory_hostname != groups['mailservers'][0] >> >> But I just don't understand what the syntax means. >> >> Thanks! >> >> -- >> 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:>. >> 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6248762f-3079-434b-83be-57a37be7b08c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
