# become: yes user: root

**URL:** <https://forum.ansible.com/t/become-yes-user-root/22816>\
**Category:** Ansible Project\
**Created:** [October 18, 2016, 12:10pm UTC](https://forum.ansible.com/t/become-yes-user-root/22816 "2016-10-18T12:10:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duncan\_Klein](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Duncan\_Klein](https://forum.ansible.com/u/Duncan_Klein)\
**Post date:** [October 18, 2016, 12:10pm UTC](https://forum.ansible.com/t/become-yes-user-root/22816/1 "2016-10-18T12:10:23Z")

</div>

Hi

Two things, related.

Firstly, I currently run my ansible playbook with --ask-sudo-pass, otherwise as some of my tasks include:

become: yes  
user: root

I get the error:

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “sudo: a password is required\n”, “module\_stdout”: “”, “msg”: “MODULE FAILURE”}

(I am currently learning how to write Ansible playbooks, and using it to control the software installed on my local machine, which is working fine).

Secondly, if I instead use:

become: yes  
user: myusername

I get:

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “This command has to be run under the root user.”}

This error is in relation to a dnf, for example:

- name: install vim  
dnf: name=vim state=latest  
become: yes  
become\_user: root

Perhaps, since the flag is --ask-sudo-pass, and not “ask su pass” or “ask root pass” or something like that, my playbook is already using sudo on my account, and I just don’t realize.  
But, barring that possibility, what is a better way for me to do this?

Thanks very much. I searched for information regarding this before posting here, but could not find clear guidance.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 20, 2016, 4:34am UTC](https://forum.ansible.com/t/become-yes-user-root/22816/2 "2016-10-20T04:34:33Z")

</div>

So ‘user’ is a deprecated form for ‘remote\_user’ which is the ‘login user’, ‘become\_user’ is the you escalate to, by default this is root so you should not need to specify it.

The password prompt tries to guess which method you are using, but it does not matter if you switch it in play as the password is still used the same.

It seems you are mixing options in incompatible ways, w/o more information I cannot even guess how. I’m not sure what you mean by ‘my playbook is already using sudo on my account’.
