Parameter |
Choices/Defaults |
Configuration |
Comments |
---|---|---|---|
_terms
required |
|
|
list of file names
|
paths
|
|
|
list of paths in which to look for the files
|
- name: show first existin file
debug: var=item
with_first_found:
- "/path/to/foo.txt"
- "bar.txt" # will be looked in files/ dir relative to play or in role
- "/path/to/biz.txt"
- name: copy first existing file found to /some/file
copy: src={{item}} dest=/some/file
with_first_found:
- foo
- "{{inventory_hostname}}
- bar
- name: same copy but specific paths
copy: src={{item}} dest=/some/file
with_first_found:
- files:
- foo
- "{{inventory_hostname}}
- bar
paths:
- /tmp/production
- /tmp/staging
- name: INTERFACES | Create Ansible header for /etc/network/interfaces
template:
src: "{{ item }}"
dest: "/etc/foo.conf"
with_first_found:
- "{{ ansible_virtualization_type }}_foo.conf"
- "default_foo.conf"
Common return values are documented here, the following are the fields unique to this lookup:
Key |
Returned |
Description |
---|---|---|
_raw
|
path to file found
|
Hint
If you notice any issues in this documentation you can edit this document to improve it.