fileglob¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in version1.4.
Synopsis¶
- Matches all files in a single directory, non-recursively, that match a pattern. It calls Python's "glob" library.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _terms required |
path(s) of files to read |
Notes¶
Note
- Patterns are only supported on files, not directory/paths.
- See R(Ansible task paths,playbook_task_paths) to understand how file lookup occurs with paths.
- Matching is against local system files on the Ansible controller. To iterate a list of files on a remote node, use the M(ansible.builtin.find) module.
- Returns a string list of paths joined by commas, or an empty list if no files match. For a 'true list' pass O(ignore:wantlist=True) to the lookup.
Examples¶
- name: Display paths of all .txt files in dir
ansible.builtin.debug: msg={{ lookup('ansible.builtin.fileglob', '/my/path/*.txt') }}
- name: Copy each file over that matches the given pattern
ansible.builtin.copy:
src: "{{ item }}"
dest: "/etc/fooapp/"
owner: "root"
mode: 0600
with_fileglob:
- "/playbooks/files/fooapp/*"
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _list | list | list of files |
Authors¶
- Michael Dehaan