# Ansible user privilege

**URL:** <https://forum.ansible.com/t/ansible-user-privilege/27211>\
**Category:** Ansible Project\
**Created:** [April 6, 2018, 7:48pm UTC](https://forum.ansible.com/t/ansible-user-privilege/27211 "2018-04-06T19:48:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quang\_Truong](https://avatars.discourse-cdn.com/v4/letter/q/e95f7d/32.png) [@Quang\_Truong](https://forum.ansible.com/u/Quang_Truong)\
**Post date:** [April 6, 2018, 7:48pm UTC](https://forum.ansible.com/t/ansible-user-privilege/27211/1 "2018-04-06T19:48:33Z")

</div>

Dear all,

I’m new to ansible and system admin on linux, I have a problem that I don’t understand what happen behind the scene.

Here is my scenario:

- I create a kvm (machine B) on my host machine, this is also an ansible control machine (machine A)
- Then copy the ssh key of the user (user X with sudoer) I will run ansible playbook from A to B
- I can run playbook with become privilege, in my playbook I install NIS and setup B to join my network domain (bind with a dns server)
- Then now the problem happen, I can’t run playbook from A to B anymore with userX

Below are the problems:

- When I put become: true (use default become\_user, should be root) for all tasks then playbook can’t gather facts from B, I got Permission denied when gathering facts  
/usr/bin/python: can’t open file ‘/home/[**userX**]/.ansible/tmp/ansible-tmp-1523038454.61-125714211155466/setup.py’: [Errno 13] Permission denied

- When I move become: true to individual task, then I have same Permission denied  
/usr/bin/python: can’t open file ‘/home/[**userX**]/.ansible/tmp/ansible-tmp-1523040035.49-151403862005878/apt.py’: [Errno 13] Permission denied

- When I try to elevate to exact user X with become\_user: userX, seems this user doesn’t have proper permission  
“changed”: false, “msg”: “Failed to lock apt for exclusive operation”

Seems I have some problems:

- root user didn’t setup properly on B so it can’t access to /home/[**userX**] directory (I read some instruction said that use ‘HOME=/root ansible-playbook my\_pb.yml …’ but still failed: OSError: [Errno 13] Permission denied: ‘~/.ansible/tmp’)
- not sure what happen with userX but it can’t execute sudo via ansible on B (although I tried to ssh with userX on B and do some sudo tasks such as apt-get install)

Please help to tell if I have miss any configurations (I think during the kvm creation, I miss some steps here)

Thanks,  
Quang

---

<div class="post-metadata">

**Author:** ![Quang\_Truong](https://avatars.discourse-cdn.com/v4/letter/q/e95f7d/32.png) [@Quang\_Truong](https://forum.ansible.com/u/Quang_Truong)\
**Post date:** [April 6, 2018, 8:58pm UTC](https://forum.ansible.com/t/ansible-user-privilege/27211/2 "2018-04-06T20:58:51Z")

</div>

Another update, I use ‘su root’ and can access to: /home/[userX]/.ansible but got permission denied when open tmp or cp directories.

---

<div class="post-metadata">

**Author:** ![Quang\_Truong](https://avatars.discourse-cdn.com/v4/letter/q/e95f7d/32.png) [@Quang\_Truong](https://forum.ansible.com/u/Quang_Truong)\
**Post date:** [April 9, 2018, 9:01pm UTC](https://forum.ansible.com/t/ansible-user-privilege/27211/3 "2018-04-09T21:01:16Z")

</div>

I tried with this guide

[https://stackoverflow.com/questions/37880491/ansible-tmp-ansible-tmp-permission-denied](https://stackoverflow.com/questions/37880491/ansible-tmp-ansible-tmp-permission-denied)

It works for my case but I don’t understand what happen behind the scene
