TECHIES WORLD

For Techs.... Techniques.... Technologies....

AWSBashCpanelLinux

How to find files using Ansible

We can use Ansible find module to find-out files.

Sample playbook snippet is given below.

- name : Find files
  find:
    paths: /var/log
    patterns: '*.log'
  register: output

- debug: var=item.path
  with_items: "{{ output.files }}"

Here the first part searching the files whose name ending with ".log" in the location "/var/log".

Second part simply prints the list of files found.

Path and patterns should be changed according to the search requirements.

That's all…

Leave a Reply