Note
This plugin is part of the community.general collection (version 2.0.1).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.filetree
.
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
_terms string / required | path(s) of files to read |
- name: Create directories ansible.builtin.file: path: /web/{{ item.path }} state: directory mode: '{{ item.mode }}' with_community.general.filetree: web/ when: item.state == 'directory' - name: Template files (explicitly skip directories in order to use the 'src' attribute) ansible.builtin.template: src: '{{ item.src }}' dest: /web/{{ item.path }} mode: '{{ item.mode }}' with_community.general.filetree: web/ when: item.state == 'file' - name: Recreate symlinks ansible.builtin.file: src: '{{ item.src }}' dest: /web/{{ item.path }} state: link force: yes mode: '{{ item.mode }}' with_community.general.filetree: web/ when: item.state == 'link' - name: list all files under web/ ansible.builtin.debug: msg: "{{ lookup('community.general.filetree', 'web/') }}"
Common return values are documented here, the following are the fields unique to this lookup:
Key | Returned | Description | |
---|---|---|---|
_raw list / elements=dictionary | success | List of dictionaries with file information. | |
ctime float | success | Time of last metadata update or creation (depends on OS). | |
gid integer | success | Group ID of the file/directory. | |
group any | success | Name of the group that owns the file/directory. | |
mode string | success | The permissions the resulting file or directory. | |
mtime float | success | Time of last modification. | |
owner any | success | Name of the user that owns the file/directory. | |
path path | success | Contains the relative path to root. | |
root path | success | Allows filtering by original location. | |
selevel any | success | The level part of the SELinux file context. | |
serole any | success | The role part of the SELinux file context. | |
setype any | success | The type part of the SELinux file context. | |
seuser any | success | The user part of the SELinux file context. | |
size integer | success | Size of the target. | |
src path | success | Full path to file. Not returned when item.state is set to directory . | |
state string | success | TODO | |
uid integer | success | Owner ID of the file/directory. |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/community/general/filetree_lookup.html