# Directory is not getting created using file module

**URL:** <https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660>\
**Category:** Get Help\
**Tags:** module, playbook, awx\
**Created:** [May 9, 2024, 8:43am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660 "2024-05-09T08:43:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaravanaSelvaraj](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/saravanaselvaraj/32/2841_2.png) [@SaravanaSelvaraj](https://forum.ansible.com/u/SaravanaSelvaraj)\
**Post date:** [May 9, 2024, 8:43am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/1 "2024-05-09T08:43:22Z")

</div>

\*\*Hello Community, I am trying to create directory using file module and it is not working as expected \*\*  
My playbook as follows

```auto
- name: creating facts directory
  ansible.builtin.file:
    path: /tmp/saravana/facts
    state: directory
    mode: '0755'
    owner: root
    group: root
  become: yes

```

And the output of it as follows,

```auto
changed: [xxxx-xxxx.xxxx.com] => {
    "changed": true,
    "diff": {
        "after": {
            "path": "/tmp/saravana/facts",
            "state": "directory"
        },
        "before": {
            "path": "/tmp/saravana/facts",
            "state": "absent"
        }
    },
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "follow": true,
            "force": false,
            "group": "root",
            "mode": "0755",
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.…

```

Can you please check what is the issue here ?

Thanks and Regards  
Saravana Selvaraj

---

<div class="post-metadata">

**Author:** ![akira6592](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akira6592/32/222_2.png) [@akira6592](https://forum.ansible.com/u/akira6592)\
**Post date:** [May 9, 2024, 9:54am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/2 "2024-05-09T09:54:59Z")

</div>

@SaravanaSelvaraj Hello!

What are you expected and actual result?

Was the directory actually created or not?

---

<div class="post-metadata">

**Author:** ![SaravanaSelvaraj](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/saravanaselvaraj/32/2841_2.png) [@SaravanaSelvaraj](https://forum.ansible.com/u/SaravanaSelvaraj)\
**Post date:** [May 9, 2024, 10:18am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/3 "2024-05-09T10:18:47Z")

</div>

Hello @akira6592 , sorry for the missout ! Yes the directory is not getting created . How can I troubleshoot this issue ?

Best regards  
Saravana Selvaraj

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [May 9, 2024, 10:42am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/4 "2024-05-09T10:42:43Z")

</div>

Which errors are you seeing?  
How are you invoking your playbook?  
Are you verifying existence / non-existance of the directory on the correct machine?

---

<div class="post-metadata">

**Author:** ![SaravanaSelvaraj](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/saravanaselvaraj/32/2841_2.png) [@SaravanaSelvaraj](https://forum.ansible.com/u/SaravanaSelvaraj)\
**Post date:** [May 9, 2024, 11:29am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/5 "2024-05-09T11:29:02Z")

</div>

Hello @jpmens , I don’t see any errors and I can see the successful output.

```auto
changed: [XXXX.com] => {
    "changed": true,
    "diff": {
        "after": {
            "path": "/tmp/saravana/facts",
            "state": "directory"
        },
        "before": {
            "path": "/tmp/saravana/facts",
            "state": "absent"
        }
    },

```

1. I am invoking the playbook using AWX.
2. Yes I am verifying on the correct machine.

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [May 9, 2024, 11:57am UTC](https://forum.ansible.com/t/directory-is-not-getting-created-using-file-module/5660/6 "2024-05-09T11:57:27Z")

</div>

Is there anything else on your playbook ? Perhaps a system reboot after that (in which case /tmp might be emptied) ? What makes you say directory isn’t there ? How did you check ?

Given the elements you provided, I’m also wondering if you are indeed checking on correct machine. Perhaps try to create your directory somewhere else, see how it goes, or move it / rename it after, put something in there then fetching it, etc… (using Ansible) to ensure it’s still there all along your playbook execution.

Maybe run your playbook using `ansible-playbook` binary instead of running it through AWX, just in case there might be another cleanup process, chained job or else involved in this ?
