ansible.builtin.fileglob (v2.6.2) — 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.6.2

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 content 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

_raw:
  description:
  - content of file(s)