Hi, I created a plugin for more complicated looping, which also covers your problem. You can find the plugin here: https://github.com/felixfontein/ansible-dependentloop With it, your problem could be solved as follows:
- name: Get the files depending on server name get_url: src=http://some_host/{{ item.1 }} when: "{{ item.0 }} in ansible_hostname" with_dependent: - "war_files.keys()" - "war_files[item.0]" Cheers, Felix On Fri, 10 Feb 2017 13:22:27 -0800 (PST) ZillaYT <[email protected]> wrote: > Say I have the following dictionary? > > war_files: > server1: > - file1.war > - file2.war > server2: > - file1.war > - file2.war > - file3.war > > > Now I want to iterate over this, say a get_url task: > > - name: Get the files depending on server name > get_url: src=http://some_host/{{ what to put here so I get each > file for the server }} > when: "{{item.key}} in ansible_hostname" > with_dict: "{{ war_files }}" > > > IOW, if role is running in server1, it'll download file1.war and > file2.war; if running on server2, it downloads file1.war, fiel2.war, > and file3.war. I know there's probably other ways to do this, but I > want to be able to do iterate through all the dictionary values in a > single task. -- 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/20170214191009.4f1945d9%40fontein.de. For more options, visit https://groups.google.com/d/optout.
