fileglob + example

This commit is contained in:
Michael Schlapa
2020-03-24 11:15:34 +01:00
parent c4ce058035
commit 1f270317bb

View File

@@ -4,6 +4,7 @@
| Module | Description | | Module | Description |
|------------------------------------------------------------------------------------------|------------------------------------------------| |------------------------------------------------------------------------------------------|------------------------------------------------|
| [file](https://docs.ansible.com/ansible/latest/modules/file_module.html) | Manage files and file properties. | | [file](https://docs.ansible.com/ansible/latest/modules/file_module.html) | Manage files and file properties. |
| [gather_facts](https://docs.ansible.com/ansible/latest/modules/gather_facts_module.html) | Gathers facts about remote hosts. |
| [lineinfile](https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html) | Manage lines in text files. | | [lineinfile](https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html) | Manage lines in text files. |
| [seport](https://docs.ansible.com/ansible/latest/modules/seport_module.html) | Manages SELinux network port type definitions. | | [seport](https://docs.ansible.com/ansible/latest/modules/seport_module.html) | Manages SELinux network port type definitions. |
| [systemd](https://docs.ansible.com/ansible/latest/modules/systemd_module.html) | Manage services. | | [systemd](https://docs.ansible.com/ansible/latest/modules/systemd_module.html) | Manage services. |
@@ -14,4 +15,21 @@
# Plugins # Plugins
| Plugin | Description | | Plugin | Description |
|------------------------------------------------------------------------------------------|-----------------------------------| |------------------------------------------------------------------------------------------|-----------------------------------|
| [gather_facts](https://docs.ansible.com/ansible/latest/modules/gather_facts_module.html) | Gathers facts about remote hosts. | | [fileglob](https://docs.ansible.com/ansible/latest/plugins/lookup/fileglob.html) | List files matching a pattern. |
# Examples
## fileglob
`fileglob` returns a comma-separated string of files matching the search string. If you append `wantlist=True` you'll get a real list. `delegate_to: localhost` lets you search on the host you're running Ansible on.
```
- hosts: localhost
remote_user: root
tasks:
- name: "Bla"
debug:
msg: "{{ lookup('fileglob', '/any/path/files/rpms/*.rpm', wantlist=True) }}"
delegate_to: localhost
```