# Bug in 0.4: Playbook with non-root user play after a root-user play fails with permissions errors

**URL:** <https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579>\
**Category:** Ansible Project\
**Created:** [May 27, 2012, 12:39am UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579 "2012-05-27T00:39:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Callender](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@John\_Callender](https://forum.ansible.com/u/John_Callender)\
**Post date:** [May 27, 2012, 12:39am UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/1 "2012-05-27T00:39:00Z")

</div>

I encountered the following today with ansible 0.4. Here’s a section of my playbook:

- hosts: dev

user: root  
tasks:

- include: tasks/yum\_common.yml

- include: tasks/cpan\_common.yml

- include: tasks/users\_common.yml

- hosts: dev

user: jbcsys  
tasks:

- include: tasks/install\_wordpress.yml

The first play runs fine, but I get the following error when the second play is being run:

PLAY [dev] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

SETUP PHASE \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [dev] =\> failed to parse: Traceback (most recent call last):

File “//home/jbcsys/.ansible/tmp/ansible.Zan2Lf/setup”, line 386, in

f = open(ansible\_file, “w+”)

IOError: [Errno 13] Permission denied: u’/etc/ansible/setup’  
/Traceback (most recent call last):

File “//home/jbcsys/.ansible/tmp/ansible.Zan2Lf/setup”, line 386, in

f = open(ansible\_file, “w+”)

IOError: [Errno 13] Permission denied: u’/etc/ansible/setup’  
/setup {  
“branch”: “master”,  
“db\_host”: “dev”,  
“group\_names”: [  
“ungrouped”  
],  
“inventory\_hostname”: “dev”,  
“ip\_address”: “209.151.236.32”,  
“jbcsysroot”: “/home/jbcsys/live”,  
“metadata”: “/etc/ansible/setup”,  
“package\_state”: “latest”,  
“www\_hostname”: “dev”  
}  
fatal: [dev] =\> failed to parse: Traceback (most recent call last):

File “//home/jbcsys/.ansible/tmp/ansible.Zan2Lf/setup”, line 386, in

f = open(ansible\_file, “w+”)

IOError: [Errno 13] Permission denied: u’/etc/ansible/setup’  
/Traceback (most recent call last):

File “//home/jbcsys/.ansible/tmp/ansible.Zan2Lf/setup”, line 386, in

f = open(ansible\_file, “w+”)

IOError: [Errno 13] Permission denied: u’/etc/ansible/setup’  
/setup {  
“branch”: “master”,  
“db\_host”: “dev”,  
“group\_names”: [  
“ungrouped”  
],  
“inventory\_hostname”: “dev”,  
“ip\_address”: “209.151.236.32”,  
“jbcsysroot”: “/home/jbcsys/live”,  
“metadata”: “/etc/ansible/setup”,  
“package\_state”: “latest”,  
“www\_hostname”: “dev”  
}

TASK: [expand wordpress installs from extern/wordpress] \*\*\*\*\*\*\*\*\*

no hosts matched or remaining

[John again]

Interestingly, if I create a separate playbook that only contains that second play, I can run it with ansible-playbook without a problem. The issue appears to be specific to my attempting to run a play as a non-root user, after running a play against the same host as the root user in the same playbook. At least, that’s my interpretation of what I’m seeing.

It seems somewhat similar to this issue:

[https://github.com/ansible/ansible/issues/353](https://github.com/ansible/ansible/issues/353)

…though I have the fix for that issue in my ansible code, and it is not helping in this case.

I can just use a workaround of using separate playbooks and wrapping them in a shell script, which I was doing already to workaround the issue with being unable to include playbooks within other playbooks. But it seems like the sort of thing that shouldn’t be happening.

I did some poking around to try to figure out more specifically what the problem was, but I’m not much of a python guy, and so far have not been able to track it down.

John

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 27, 2012, 12:53am UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/2 "2012-05-27T00:53:45Z")

</div>

You're not showing the full playbook in this email so it's hard to say, but when not using the root user the code is \*supposed\* to not use /etc/ansible/setup as the metadata location.

If you can work the playbook down to the minimal example and paste it contiguously, that would be useful.

--Michael

---

<div class="post-metadata">

**Author:** ![John\_Callender](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@John\_Callender](https://forum.ansible.com/u/John_Callender)\
**Post date:** [May 27, 2012, 4:39am UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/3 "2012-05-27T04:39:10Z")

</div>

Sorry about that. Here’s a minimal version with the full playbook that demonstrates the issue:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 30, 2012, 7:42pm UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/4 "2012-05-30T19:42:20Z")

</div>

Thanks, that will be very useful. Please make sure this is filed in  
github so we can keep track of open issues.

--Michael

---

<div class="post-metadata">

**Author:** ![John\_Callender](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@John\_Callender](https://forum.ansible.com/u/John_Callender)\
**Post date:** [May 31, 2012, 7:48pm UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/5 "2012-05-31T19:48:21Z")

</div>

I’ve created an issue now. See:

[https://github.com/ansible/ansible/issues/440](https://github.com/ansible/ansible/issues/440)

Thanks.

John

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [June 1, 2012, 2:23am UTC](https://forum.ansible.com/t/bug-in-0-4-playbook-with-non-root-user-play-after-a-root-user-play-fails-with-permissions-errors/11579/6 "2012-06-01T02:23:00Z")

</div>

Fixed on devel branch.

SETUP\_CACHE wasn't being reset between plays.
