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.
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.
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!
Works now. Thanks!
Oliver
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
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!