# file Module behaviour with directories in check mode

**URL:** <https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [April 25, 2013, 9:14pm UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721 "2013-04-25T21:14:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 25, 2013, 9:14pm UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721/1 "2013-04-25T21:14:52Z")

</div>

So if I may summarize, check mode doesn’t work on directories? Or is it something more specific?

Yes, this sounds like a minor bug to me and should not be the case.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 26, 2013, 1:35am UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721/2 "2013-04-26T01:35:45Z")

</div>

Pushed a fix for this. There were some other parts of the file module that didn’t do check mode well, as you say, which I think we missed because we tended to focus on check mode for copy and template.

If you update to the latest 1.2 there is much more extense check mode checking.

Thanks for the report!

---

<div class="post-metadata">

**Author:** ![Oliver\_Heinz](https://avatars.discourse-cdn.com/v4/letter/o/db5fbb/32.png) [@Oliver\_Heinz](https://forum.ansible.com/u/Oliver_Heinz)\
**Post date:** [April 28, 2013, 10:22am UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721/3 "2013-04-28T10:22:36Z")

</div>

Works now. Thanks!

Oliver

---

<div class="post-metadata">

**Author:** ![Oliver\_Heinz](https://avatars.discourse-cdn.com/v4/letter/o/db5fbb/32.png) [@Oliver\_Heinz](https://forum.ansible.com/u/Oliver_Heinz)\
**Post date:** [April 30, 2013, 10:06am UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721/4 "2013-04-30T10:06:39Z")

</div>

Sorry have to correct myself. It does not create the directory in check mode any more - good 🙂

But behaviour is still not what I would expect.  
After running the playbook (non-check) the directories are created and ownerships are changed. When I run the same playbook in check-mode after that it tells me that it would change the directories nevertheless.

TIA,  
Oliver

**1st run (directories are created)**

root@ansible:~/ansible/playbooks# ansible-playbook -l localhost -i hosts -v site.yml

PLAY [deployment-clients] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[…]  
TASK: [create sites dir] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost] =\> (item=TEST) =\> {“changed”: true, “gid”: 100, “group”: “users”, “item”: “TEST”, “mode”: “02775”, “owner”: “autoupdate”, “path”: “/var/www/TEST/sites”, “size”: 4096, “state”: “directory”, “uid”: 999}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=9 changed=4 unreachable=0 failed=0

**2nd run: everything is o.k.**

root@ansible:~/ansible/playbooks# ansible-playbook -l localhost -i hosts -v site.yml

PLAY [deployment-clients] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[…]  
TASK: [create sites dir] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> (item=TEST) =\> {“changed”: false, “gid”: 100, “group”: “users”, “item”: “TEST”, “mode”: “02775”, “owner”: “autoupdate”, “path”: “/var/www/TEST/sites”, “size”: 4096, “state”: “directory”, “uid”: 999}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=9 changed=0 unreachable=0 failed=0

**3rd run (this time in check-mode): directory checks show changed where they should show o.k.**

root@ansible:~/ansible/playbooks# ansible-playbook -l localhost -i hosts -C -v site.yml

PLAY [deployment-clients] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[…]  
TASK: [create sites dir] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost] =\> (item=TEST) =\> {“changed”: true, “gid”: 100, “group”: “users”, “item”: “TEST”, “mode”: “02775”, “owner”: “autoupdate”, “path”: “/var/www/TEST/sites”, “size”: 4096, “state”: “directory”, “uid”: 999}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=9 changed=6 unreachable=0 failed=0

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 30, 2013, 7:44pm UTC](https://forum.ansible.com/t/file-module-behaviour-with-directories-in-check-mode/12721/5 "2013-04-30T19:44:35Z")

</div>

Ok, so the changed bits are off, but it’s still better than making the directories. Got it. Less severe by a huge stretch but still a little broke for reporting whether it’s compliant for state=directory or not.

Can you file a separate bug for this?

Thank you!
