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
--
--
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/b79e39bf-4ff6-3bba-b042-508e1d9f62a3%40ufz.de.
For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME Cryptographic Signature
