# integration tests: atomic\_copy fails when trying to chown from root to nobody as nobody

**URL:** <https://forum.ansible.com/t/integration-tests-atomic-copy-fails-when-trying-to-chown-from-root-to-nobody-as-nobody/16211>\
**Category:** Ansible Developer\
**Created:** [September 13, 2014, 7:34pm UTC](https://forum.ansible.com/t/integration-tests-atomic-copy-fails-when-trying-to-chown-from-root-to-nobody-as-nobody/16211 "2014-09-13T19:34:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [September 13, 2014, 7:34pm UTC](https://forum.ansible.com/t/integration-tests-atomic-copy-fails-when-trying-to-chown-from-root-to-nobody-as-nobody/16211/1 "2014-09-13T19:34:17Z")

</div>

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  
&nbsp;&nbsp;file: dest=/tmp/worldwritable state=directory mode=0777

- name: create world writable file  
&nbsp;&nbsp;copy: dest=/tmp/worldwritable/file.txt content="bar" mode=0666

- name: overwrite the file as user nobody  
&nbsp;&nbsp;copy: dest=/tmp/worldwritable/file.txt content="baz"  
&nbsp;&nbsp;sudo: yes  
&nbsp;&nbsp;sudo\_user: nobody  
&nbsp;&nbsp;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?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 14, 2014, 5:13pm UTC](https://forum.ansible.com/t/integration-tests-atomic-copy-fails-when-trying-to-chown-from-root-to-nobody-as-nobody/16211/2 "2014-09-14T17:13:25Z")

</div>

Hi Michael,

Ansible integration tests are clean in our Jenkins instance. I’d make sure you are running integration tests (though I’d clearly suggest a VM) as root.

–Michael
