# ansible error fpr sudo user

**URL:** <https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743>\
**Category:** Ansible Project\
**Created:** [February 22, 2019, 1:28pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743 "2019-02-22T13:28:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 1:28pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/1 "2019-02-22T13:28:18Z")

</div>

Hello Experts,

I had a working playbook in my test environment, where my user was root user itslef and didnt have any issue.  
When i moved my playbook to staging environment , there my login user account is “admin” which is sudo user. But all of my playbooks are failing in this environment.

`

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 22, 2019, 1:36pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/2 "2019-02-22T13:36:14Z")

</div>

Have this in your playbook:

become: true

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 1:49pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/3 "2019-02-22T13:49:52Z")

</div>

Hello Sudeer… No luck.

`

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 22, 2019, 1:52pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/4 "2019-02-22T13:52:22Z")

</div>

Logon to the server manually as admin and try doing something like `sudo ls`. See if password is required on the server.

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 1:59pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/5 "2019-02-22T13:59:01Z")

</div>

Hello Sudheer,

Yes, Password required for any action . because my user “admin” is created and added to sudoers group in staging environment where the playbook is failing.

Whereas in my development environment the playbook was working as there i jhad root user password.

---

<div class="post-metadata">

**Author:** ![Georg\_Grossmann](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@Georg\_Grossmann](https://forum.ansible.com/u/Georg_Grossmann)\
**Post date:** [February 22, 2019, 2:04pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/6 "2019-02-22T14:04:48Z")

</div>

Have you tried the -K flag?  
Try

`  
ansible-playbook -K yourplaybook.yaml

`

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 2:14pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/7 "2019-02-22T14:14:42Z")

</div>

Hello Georg,

Yes, tried.

Please find the error below.

`

ansible-playbook silentiInstallerfile1.yml -k  
SSH password:

PLAY [Replace the silent-install-server\_ file to each Application Servers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [10.16.24.103]: FAILED! =\> {“changed”: false, “module\_stderr”: “Shared connection to 10.16.24.103 closed.\r\n”, “module\_stdout”: “sudo: a password is required\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}  
fatal: [10.16.24.102]: FAILED! =\> {“changed”: false, “module\_stderr”: “Shared connection to 10.16.24.102 closed.\r\n”, “module\_stdout”: “sudo: a password is required\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}  
ok: [localhost]

TASK [check the folder existance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [JTS Server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost → localhost]

TASK [CCM Server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “Failed to get information on remote file (/opt/CLM-Web-Installer-Linux-6.0.5/im/linux.gtk.x86\_64/silent-install-server\_CCM.xml): Shared connection to 10.16.24.102 closed.\r\n”}  
to retry, use: --limit @/etc/ansible/roles/IBM2/tasks/best/silentiInstallerfile1.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.16.24.102 : ok=0 changed=0 unreachable=0 failed=1  
10.16.24.103 : ok=0 changed=0 unreachable=0 failed=1  
localhost : ok=3 changed=0 unreachable=0 failed=1

`

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 22, 2019, 2:19pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/8 "2019-02-22T14:19:39Z")

</div>

For such situations, I would enable the 'admin' user to escalate privileges with sudo without specifying password. You can configure sudoer's to escalate privilege without password.

Would that resolve your problem?

---

<div class="post-metadata">

**Author:** ![Keif\_Gwinn](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@Keif\_Gwinn](https://forum.ansible.com/u/Keif_Gwinn)\
**Post date:** [February 22, 2019, 2:20pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/9 "2019-02-22T14:20:31Z")

</div>

it looks like it needs a password to escalate, have a look at [https://docs.ansible.com/ansible/latest/user\_guide/become.html#connection-variables](https://docs.ansible.com/ansible/latest/user_guide/become.html#connection-variables) to set an escalation password.

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 2:46pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/10 "2019-02-22T14:46:40Z")

</div>

Hello sudeer,

Yes. I had added the user admin to sudoers and made password less as same as given for root user in the sudoers file.

But still no luck

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 2:48pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/11 "2019-02-22T14:48:45Z")

</div>

Hello kief,

I already tried with different options of become as given in the link  
But couldn’t resolve . I am not sure that which part of the playbook which I need to modify inorder to make it run for admin user.

Where this playbook is working fine in another environmental where using root user

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 22, 2019, 2:50pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/12 "2019-02-22T14:50:23Z")

</div>

I would first make sure that sudoer configuration is correct on the target server. So, logon to server manually and make sure you can use sudo without password.

---

<div class="post-metadata">

**Author:** ![Keif\_Gwinn](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@Keif\_Gwinn](https://forum.ansible.com/u/Keif_Gwinn)\
**Post date:** [February 22, 2019, 2:54pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/13 "2019-02-22T14:54:18Z")

</div>

> But couldn’t resolve . I am not sure that which part of the playbook which I need to modify inorder to make it run for admin user.

I’ve been doing a lot of become work the last day, I found it’s designed to work on a task level in roles but does this work?

- name: Replace the silent-install-server\_ file to each Application Servers  
hosts: localhost,CCM,RM  
vars:  
jts\_file: /etc/ansible/roles/IBM2/files/silent-install-server\_JTS.xml  
ccm\_file: /etc/ansible/roles/IBM2/files/silent-install-server\_CCM.xml  
rm\_file: /etc/ansible/roles/IBM2/files/silent-install-server\_RM.xml  
dest\_dir: /opt/CLM-Web-Installer-Linux-6.0.5/im/linux.gtk.x86\_64  
ansible\_become: yes  
ansible\_become\_user: root  
ansible\_become\_pass: “{{rootpass}}”  
tasks:

- name: check the folder existance  
stat: path=/opt/CLM-Web-Installer-Linux-6.0.5/im/linux.gtk.x86\_64  
register: folder\_exist

- name: JTS Server  
copy:  
src: “{{ jts\_file }}”  
dest: “{{ dest\_dir }}/”  
mode: 777  
backup: yes  
delegate\_to: localhost  
when: folder\_exist.stat.exists == True

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 2:59pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/14 "2019-02-22T14:59:15Z")

</div>

Hello Sudheer,

Verified in all the servers and this was enabled already.

## Allow root to run any commands anywhere

root ALL=(ALL) NOPASSWD: ALL  
admin ALL=(ALL) NOPASSWD: ALL

---

<div class="post-metadata">

**Author:** ![Vivek1](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vivek1](https://forum.ansible.com/u/Vivek1)\
**Post date:** [February 22, 2019, 3:09pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/15 "2019-02-22T15:09:20Z")

</div>

`

ansible-playbook -k silentiInstallerfile1.yml  
SSH password:  
ERROR! ‘ansible\_become\_user’ is not a valid attribute for a Play

The error appears to have been in ‘/etc/ansible/roles/IBM2/tasks/best/silentiInstallerfile1.yml’: line 3, column 3, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Replace the silent-install-server\_ file to each Application Servers  
^ here

`

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 22, 2019, 5:24pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/16 "2019-02-22T17:24:24Z")

</div>

Are you both representing the same organization and hence the same problem?

I am confused by multiple situations:

"Yes. I had added the user admin to sudoers and made password less as same as given for root user in the sudoers file." - vivuu1989@gmail.com  
"Yes, Password required for any action . because my user "admin" is created and added to sudoers group in staging environment where the playbook is failing." - visar \<vivuu1989@gmail.com\>

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [February 22, 2019, 6:09pm UTC](https://forum.ansible.com/t/ansible-error-fpr-sudo-user/29743/17 "2019-02-22T18:09:28Z")

</div>

One more point to verify :

Are you connected with admin user on the controller-server (where you play your playbook) ?

If not you should use remote\_user to admin…

Perhaps a verbose log error could help… use -vvvv when playing ansible-playbook

Regards,

JYL
