Hi,
Is there a way to do the same as “with_items” but globally for the playbook?
For example something like :
variable1:
and use it like this in the playbook.
- name: Download something
get_url:
url=“{{ variable1.url }}”
dest=“/tmp/{{ variable1.dest}}”
and in an other place use the same infos
- name: Extract
unarchive:
src=/tmp/{{ variable1.src}}
dest=/tmp/ copy=no
Hi,
Is there a way to do the same as "with_items" but globally for the playbook?
For example something like :
variable1:
- {url: 'http://someting', dest: 'something', src: 'something'}
- {url: 'http://someting2', dest: 'something2', src: 'something2'}
This will work.
and use it like this in the playbook.
- name: Download something
get_url:
url="{{ variable1.url }}"
dest="/tmp/{{ variable1.dest}}"
and in an other place use the same infos
- name: Extract
unarchive:
src=/tmp/{{ variable1.src}}
dest=/tmp/ copy=no
But this will not. Since it is a list you need to specify which list item you want.
Fist item (someting):
{{ variable1[0].url }}
Second item (someting2):
{{ variable1[1].url }}
Hi,
Thank you. I find this way of doing to do what I need with your help :
vars:
modules:
- {name: ‘test’, url: ‘https://url’, archive: ‘test.ar.gz’}
- {name: ‘test2’, url: ‘https://url2’, archive: ‘test.zip’}
tasks:
- name: Extract archives
unarchive:
src=/tmp/{{ item.archive}}
dest=/tmp/modules copy=no
with_items: “{{ modules }}”