Hi - I’m looking for a way to unarchive an array of files and want to use different ‘creates’ checks for each.
------Vars-------
sources :
- WAS_V8.5.5_1_OF_3.zip
- WAS_V8.5.5_2_OF_3.zip
- WAS_V8.5.5_3_OF_3.zip
------Tasks------
- name: unarchive source to target
sudo: yes
unarchive: src={{ item }} dest=/opt/WAS_{{ version }} copy=yes creates=/opt/WAS_{{ version }}/disk{{ item.index|int +1 }}/diskTag.inf
with_items: “{{ sources }}”
The above code is trying to check for a file …/disk1/diskTag.inf for the first entry in the array, …/disk2/diskTag.inf for the second and so on. While the unarchive does seem to loop on the src correctly the creates always references the item with index 0. Trace output below. Any thoughts on if this is possible in Ansible. My fallback is an unarchive per entry but its not ideal.
ok: [10.108.122.113] => (item=WAS_V8.5.5_1_OF_3.zip) => {“changed”: false, “item”: “WAS_V8.5.5_1_OF_3.zip”, “msg”: “skipped, since /opt/WAS_8.5.5/disk1/diskTag.inf exists”}
ok: [10.108.122.113] => (item=WAS_V8.5.5_2_OF_3.zip) => {“changed”: false, “item”: “WAS_V8.5.5_2_OF_3.zip”, “msg”: “skipped, since /opt/WAS_8.5.5/disk1/diskTag.inf exists”}
ok: [10.108.122.113] => (item=WAS_V8.5.5_3_OF_3.zip) => {“changed”: false, “item”: “WAS_V8.5.5_3_OF_3.zip”, “msg”: “skipped, since /opt/WAS_8.5.5/disk1/diskTag.inf exists”}