Let me as a different question. What If I want to show ALL the files in a
debug task, like this
- debug: msg="Key = {{ item.key }} values = {{ item.value }}"
with_dict: "{{ war_files }}"
I want to see an output like this
"msg" : "Key = server1 value = file1.war"
"msg" : "Key = server1 value = file2.war"
"msg" : "Key = server2 value = file1.war"
"msg" : "Key = server2 value = file2.war"
"msg" : "Key = server2 value = file3.war"
IOW, I want to iterate over the keys, then the values in each key.
On Friday, February 10, 2017 at 4:57:23 PM UTC-5, Kai Stian Olstad wrote:
>
> On 10. feb. 2017 22:22, ZillaYT 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.
>
> - name: Get the files depending on server name
> get_url: src=http://some_host/{{ item }}
> with_items: "{{ war_files[ansible_hostname] }}"
>
>
> --
> Kai Stian Olstad
>
--
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/059c8f3f-db2e-419b-a505-f542a1b24625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.