Werner Flamme [07.06.2016 15:52]:
> Hi everyone,
>
> I have to copy a file (on the client) to a certain location (also on the
> client).
>
> I know the copy module, but my problem is the source location. The
> filename is always the same, like foo.pem.
[...]
JFTR:
By reading "Mastering Ansible", written by by Jesse Keating, I found out
about the stat module, "set_facts" and registered variables in loops...
So I think I solved my problem now with two tasks:
=== snip ===
- vars:
mydirlist:
- in_2014
- in_2014_09
- in_2015
- in_2016
mytargetdir: 'nonsense'
- name: figuring the directory
stat: path=/some/dir/{{ ansible_hostname }}/{{ item }}
register: fig1
with_items: "{{ mydirlist }}"
- name: note the first found path
set_fact: mytargetdir="{{ item.stat.path }}"
with_items: "{{ fig1.results }}"
when: mytargetdir == 'nonsense' and item.stat.exists == True
=== pins ===
Regards,
Werner
--