Extracting file persmission data in Ansible

2.7k views Asked by At

I want to build a playbook to check File permissions of all the files in a directory and then create a report containing its details using Ansible.

I tried using ACL module for this purpose but I can't understand where is the return list getting stored ?

2

There are 2 answers

0
Bruce P On

As the examples for the ACL module show:

# Obtain the acl for a specific file
- acl: name=/etc/foo.conf
  register: acl_info

To then look at the results:

- debug: var=acl_info

That should get you started. The debug task will display the full results of what was retrieved by the acl module.

2
VSK On

Ansible files module - find command can list all the files in a directory with the file permissions

    tasks:
  - name: list of files
    find: paths="/tmp" recurse=yes file_type=file
    register: list_of_files
  - debug: msg="{{ list_of_files.files }}" 

The result will have the mode of the file say 0777 or 0600 etc.