I was trying to get the integration tests (non_destructive) running
(with sudo) but ran into a failure.
TASK: [test_copy | overwrite the file as user nobody] *************************
failed: [testhost] => {"failed": true, "md5sum":
"73feffa4b7f6bb68e44cf984c85f6e88"}
msg: Could not replace file:
/tmp/ansible-tmp-1410636452.39-163327871394273/source to
/tmp/worldwritable/file.txt: [Errno 1] Operation not permitted:
'/tmp/worldwritable/.ansible_tmpyXnmmVfile.
Those task looks like this:
- name: create world writable directory
file: dest=/tmp/worldwritable state=directory mode=0777
- name: create world writable file
copy: dest=/tmp/worldwritable/file.txt content="bar" mode=0666
- name: overwrite the file as user nobody
copy: dest=/tmp/worldwritable/file.txt content="baz"
sudo: yes
sudo_user: nobody
register: copy_result7
The failure isn't in the copy (it uses shutil.copy2 because the
os.rename fails because of permissions as expected) which succeeds.
It's in the chown that happens a few lines later. The chown is
triggered because the tmp file and the destination have different
ownership.
I'm having a hard time seeing how this test could succeed. The
original file is owned by root, but is read/writeable by everyone. So
the nobody user can copy over the file, but it can't change it's
ownership.
Am I missing something?