user3614014
user3614014

Reputation: 673

ansible file and directory permissions

Trying to get ansible file/directory permissions to work.

In ansible I create a user:

user: name=testuser shell=/sbin/nologin uid=1234 comment="Test User"

Then I try to change ownership of a file directory:

file: path=/etc/myfile state=directory owner=testuser group=testuser mode=0644 recurse=yes

I also have tried setting a facl for a file:

acl:
     name: /var/log/audit/audit.log
     entity: filebeat
     etype: user
     permissions: rx
     state: present

When observing the file permissions and the facl, they appear to be set correctly. However if I change the shell of my test user and login, I discover that I don't actually have the permissions that ansible presumably set. I keep getting a "Permission Denied" message.

Upvotes: 0

Views: 2771

Answers (1)

gile
gile

Reputation: 5996

If I understand what you mean, you get "Permission denied" when you try accessing to the directory content, e.g. running ls -l /etc/myfile . This is the right *nix behaviour because you setted acces permission to mode=0644.

About directories, the execute bit allows the affected user to enter the directory, and access files and directories inside.

So, to allow your testuser going through the directory, set at least mode=0744.

To allow testuser group mode=0754 and to allow everybody mode=0755

Upvotes: 0

Related Questions