Thank you Matt! hosts.keys() is exactly what I was looking for. I've been using hosts as the dict name for almost a year with no known issues, but I'm going to follow your advice and rename it as soon as I get a chance, thanks for the suggestion.
On Tuesday, May 19, 2015 at 2:30:49 PM UTC-7, Matt Martz wrote: > > This is probably a better question for ansible-project since it isn't > related to developing ansible. > > However, to answer your question: > > with_items: hosts.keys() > > I would also suggest you pick a variable other than hosts, to prevent any > naming collision with internal variables. > > On Tue, May 19, 2015 at 4:25 PM, Michael Bushey <[email protected] > <javascript:>> wrote: > >> I have a dict: >> >> hosts: >> web01: >> int_ip: 192.168.1.1 >> ext_ip: 1.2.3.4 >> web02: >> int_ip: 192.168.1.2 >> ext_ip: 1.2.3.5 >> >> I am using a template that I supply items to with "with_items", and I >> reference the data as "item". If I use "with_dict", then the template has >> to be duplicated and "item" changed to "item.key". In this example I would >> like to get a list containing web01 and web02 from the dict hosts. >> >> I would like to do something like: >> with_items: hosts.key >> when: item[:3] == 'web' >> >> Any ideas? Thanks! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Development" 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/d/optout. >> > > > > -- > Matt Martz > @sivel > sivel.net > -- 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/26310c98-d3c0-4e47-bfa1-86184a944bcc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
