The file module failing when directory exists

119 views
Skip to first unread message

Igor Cicimov

unread,
Nov 16, 2015, 2:06:53 AM11/16/15
to Ansible Project
Hi all,

Currently a task like this:

file: path=/data state=directory owner=root group=root mode=0755

fails with the following error:

failed: [localhost] => {"failed": true, "parsed": false}
BECOME-SUCCESS-pquapqcakqrmffxonpxknqbulycqfmls
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1447656411.96-95869428580440/file", line 2012, in <module>
    main()
  File "/root/.ansible/tmp/ansible-tmp-1447656411.96-95869428580440/file", line 279, in main
    os.mkdir(curpath)
OSError: [Errno 17] File exists: '/data'

on Ansible 1.9.4. Doesn't it make more sense for the task to continue and just set the permissions instead of failing when the directory already exists?

Thanks,
Igor

Markus Ellers

unread,
Nov 16, 2015, 1:23:57 PM11/16/15
to Ansible Project
hi, are you sure the remote ansible user is allowed to change folder owners / permissions in the / directory?

Igor Cicimov

unread,
Nov 16, 2015, 4:48:14 PM11/16/15
to Ansible Project
Absolutely sure. This should be easily reproducible if you are willing to try it.

Tim Fletcher

unread,
Nov 16, 2015, 5:21:51 PM11/16/15
to ansible...@googlegroups.com
Is it a directory or a file?

I have come across this error when a file existed which I requested be a
directory.


signature.asc

Igor Cicimov

unread,
Nov 16, 2015, 5:47:31 PM11/16/15
to Ansible Project
Directory.
Reply all
Reply to author
Forward
0 new messages