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

**URL:** <https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860>\
**Category:** Ansible Project\
**Created:** [July 24, 2019, 2:58pm UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860 "2019-07-24T14:58:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minal\_Deshmukh](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Minal\_Deshmukh](https://forum.ansible.com/u/Minal_Deshmukh)\
**Post date:** [July 24, 2019, 2:58pm UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860/1 "2019-07-24T14:58:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 24, 2019, 7:31pm UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860/2 "2019-07-24T19:31:30Z")

</div>

How do you create the directory?

I.E. what does your playbook look like?

---

<div class="post-metadata">

**Author:** ![Minal\_Deshmukh](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Minal\_Deshmukh](https://forum.ansible.com/u/Minal_Deshmukh)\
**Post date:** [July 25, 2019, 5:16am UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860/3 "2019-07-25T05:16:52Z")

</div>

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

[perry.in.rdlabs.hpecorp.net](http://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

---

<div class="post-metadata">

**Author:** ![P.Cookson](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@P.Cookson](https://forum.ansible.com/u/P.Cookson)\
**Post date:** [July 25, 2019, 7:49am UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860/4 "2019-07-25T07:49:29Z")

</div>

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](https://docs.ansible.com/ansible/latest/modules/file_module.html#file-module)

Regards

Phil

---

<div class="post-metadata">

**Author:** ![Minal\_Deshmukh](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Minal\_Deshmukh](https://forum.ansible.com/u/Minal_Deshmukh)\
**Post date:** [July 25, 2019, 9:59am UTC](https://forum.ansible.com/t/ansible-creates-a-directory-with-full-permissions-even-though-umask-is-set-to-022-on-the-managed-node/30860/5 "2019-07-25T09:59:18Z")

</div>

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
