ansible.builtin.fileglob (v2.8.18) — lookup

list files matching a pattern

| "added in version" 1.4 of ansible.builtin"

Authors: Michael DeHaan <michael.dehaan@gmail.com>

Install Ansible via pip

Install with pip install ansible==2.8.18

Description

Matches all files in a single directory, non-recursively, that match a pattern. It calls Python's "glob" library.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Display paths of all .txt files in dir
  debug: msg={{ lookup('fileglob', '/my/path/*.txt') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Copy each file over that matches the given pattern
  copy:
    src: "{{ item }}"
    dest: "/etc/fooapp/"
    owner: "root"
    mode: 0600
  with_fileglob:
    - "/playbooks/files/fooapp/*"

Inputs

    
_terms:
    description: path(s) of files to read
    required: true

Outputs

_list:
  description:
  - list of files