# become\_user for a given task is not honored when I run shells or scripts on nodes

**URL:** <https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099>\
**Category:** Ansible Project\
**Created:** [March 23, 2018, 5:54pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099 "2018-03-23T17:54:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Collins](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Gary\_Collins](https://forum.ansible.com/u/Gary_Collins)\
**Post date:** [March 23, 2018, 5:54pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/1 "2018-03-23T17:54:13Z")

</div>

In my real playbook, I need to add new user myuser , then install home-brew for that user.

This is my command line to run below.

uadmin is the only user initially configured on machine given to me.

When I run below it install homebrew for uadmin and not as mach5-one

If I run each part of my real playbook from command line as uadmin to install user, then as myuser for everything else

it install homebrew as myuser… But that defeats the one play to install all parts and defining who to run things as.

I must be missing something real simple… if I add become: yes then I get permission issues

Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: /tmp/ansible-tmp-1521827588.02-202609912949198/: Operation not permitted

chown: /tmp/ansible-tmp-1521827588.02-202609912949198/stat.py: Operation not permitted

}). For information on working around this, see [https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user](https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user)

Thanks for any help,

Gary

ansible-playbook -u uadmin -k -K -i hosts myhost some.yml --tags homebrew2

some.yml

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 23, 2018, 5:58pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/2 "2018-03-23T17:58:56Z")

</div>

You set become\_user, but you don't enable become itself? try adding become: yes

---

<div class="post-metadata">

**Author:** ![Gary\_Collins](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Gary\_Collins](https://forum.ansible.com/u/Gary_Collins)\
**Post date:** [March 23, 2018, 7:29pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/3 "2018-03-23T19:29:47Z")

</div>

if I add become: yes then I get permission issues

Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: /tmp/ansible-tmp-1521827588.02-202609912949198/: Operation not permitted

chown: /tmp/ansible-tmp-1521827588.02-202609912949198/stat.py: Operation not permitted

}). For information on working around this, see [https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user](https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user)

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 23, 2018, 7:50pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/4 "2018-03-23T19:50:07Z")

</div>

Have you read the error message and done what it says?

---

<div class="post-metadata">

**Author:** ![Gary\_Collins](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Gary\_Collins](https://forum.ansible.com/u/Gary_Collins)\
**Post date:** [March 23, 2018, 8:55pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/5 "2018-03-23T20:55:40Z")

</div>



---

<div class="post-metadata">

**Author:** ![Gary\_Collins](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Gary\_Collins](https://forum.ansible.com/u/Gary_Collins)\
**Post date:** [March 23, 2018, 8:59pm UTC](https://forum.ansible.com/t/become-user-for-a-given-task-is-not-honored-when-i-run-shells-or-scripts-on-nodes/27099/6 "2018-03-23T20:59:25Z")

</div>

The only way I see to get it to work is to `allow_world_readable_tmpfiles` in the `ansible.cfg`  
This seems like a messy solution… Returns the follow warning.

**[WARNING]: Using world-readable permissions for temporary files Ansible needs to create when becoming an unprivileged user. This may be insecure. For information on securing this, see**

**[https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user](https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user)**

**Seems Kind of a hack solution… If I broke up the add user into 1 playbook. then ran using uadmin to add user, then the rest of the playbook in another and run**

**as myuser then all is well. But the defeats the become\_user defines in the code.**
