Suppose there's a directory /dir/tools. tools contains a bunch of scripts, say, a.sh, b.sh, c.sh.
I need to set the permissions of a.sh, b.sh, and c.sh to 0775.
I've currently done it in the following manner:
- name: Fix 'support_tools' permissions
file: path={{ item }} owner=abc group=abc mode=0775
with_items:
- /dir/tools/a.sh
- /dir/tools/b.sh
- /dir/tools/c.sh
Btw, 'file: path=/dir/tools owner=abc group=abc mode=0775' sets the permission of tools directory but not of the files inside it.
Is there a better way of achieving this?
To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.
Btw, 'file: path=/dir/tools owner=abc group=abc mode=0775' sets the permission of tools directory but not of the files inside it.
We can change the permissions of files and directories using the chmod command. There are two ways to change permission: Using short/soft/symbolic codes. Using octal codes.
Try:
- name: Fix 'support_tools' permissions
file: path=/dir/tools owner=abc group=abc mode=0775 state=directory recurse=yes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With