Ansible creates a directory with full permissions even though umask is set to "022" on the managed node

Hello Ansible experts,

I am struck with this issue.
Could you please help me on this.

If I create a directory using Ansible on the managed node it creates it with full permissions.
umask on the managed node in not honored.

Thank you so much!

Regards,
Minal

How do you create the directory?

I.E. what does your playbook look like?

Using Ansible for node \perry which is managed node:
root@ubuntu:~# ansible perry -a umask

perry.in.rdlabs.hpecorp.net | SUCCESS | rc=0 >>
00

Manually on \perry:
Wheras on the \perry it is as below

/home/super: umask
0022

My concern here is before going to even a playbook, Ansible sets umask wrongly or not able to fetch umask from the managed node correctly.

Regards,
Minal

Hi Minal

Could do with more detail, really, as you don’t say what method you’re using. However the “mode” option with the “file” module would accommodate this. See eg and link below:

- name**:** Create a directory if it does not exist

file**:**

path**:** /etc/some_directory

state**:** directory

mode**:** ‘0755’

https://docs.ansible.com/ansible/latest/modules/file_module.html#file-module

Regards

Phil

Hi Phil,

Thank you for your response.

I wrote my custom ansible modules and in that we create a directory using a python os module.

Snippet:
os.mkdir(path)

Regards,
Minal