Skip to content

jvale/ansible_existing_files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

existing_files

Ansible lookup plugin that, given a list files and paths, returns all the ones that exist. This is useful to avoid the pattern of having to stat a series of files to check if they exist before operating on them.

Heavily derived from Ansible's first_found lookup plugin, so all the rules that it applies to files and paths also apply here.

Example usage

- name: read vars from all files that actually exist
  include_vars: "{{ item }}"
  loop: "{{ query('existing_files', params) }}"
  vars:
    params:
      files:
        - '{{ ansible_os_distribution }}.yml'
        - '{{ ansible_os_family }}.yml'
        - default.yml
      paths:
        - 'vars'

About

Ansible lookup plugin to filter all existing files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages