Bobcares

Ansible Error Missing Sudo Password: Solution

by | Nov 14, 2022

let us examine the error  Ansible error missing sudo password and the troubleshooting steps to remove the error with the support of our Server management support services at Bobcare.

 Ansible Error Missing Sudo Password

ansible error missing sudo password

 

Troubleshoots

The troubleshooting for the error is as shown below:

$ ansible-playbook --help usage: ansible-playbook [-h] [--version] [-v] [-k] [--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER] [...]Copy Code

Privilege Escalation Options: Control how and which user we become as a target host.

Begin operations with (does not imply password prompting):

verification

For Verification follow the codes given below:

Solve: Ansible error missing Sudo Password

Use the following troubleshooting methods to remove the error:

Troubleshoots

Firstly use the:

/etc/sudoers.d/devops
devops ALL=(ALL) NOPASSWD: ALLCopy Code

Follow the command line given below to learn about the solution execution:

2

Try the option

-kKCopy Code
. It will prompt for a password.

3

When running the Ansible playbook, we can specify the sudo password:

ansible-playbook playbook.yml -i inventory.ini --extra-vars "ansible_sudo_pass=userPassword"Copy Code

4

Add the following contents to the postgres file in the target machine’s  /etc/sudoers.d directory:

postgres ALL=(ALL) NOPASSWD:ALLCopy Code

This guarantees that the postgres user (if we’re using it as the sudo user) isn’t prompted for a password when attempting sudo commands. If we use a different user to connect to the target system, we must change the above to grant that user the NOPASSWD permission instead.

5

Consider adding the information to the servers group variables in one scenario. So in

/etc/ansible/group_vars/{servergroup}/vars Copy Code
we have included the following:

6

In one situation, the issue might be that the ansible user does not have all of the necessary permissions. The tester user did not have all of the sudo permissions required to conduct the following operations:

Initial tester_user permission:Copy Code
tester ALL= NOPASSWD:ALLCopy Code

changed to remove the ansible error missing sudo password:

tester ALL=(ALL:ALL) NOPASSWD:ALLCopy Code

These new fields have the following meaning: The first “ALL” specifies that the user has the ability to perform commands as all users. The second “ALL” indicates that the user has permission to execute commands as all groups.

It is required that the ansible user be able to perform commands since all Ansible users utilize become user.

7

If we pick the ‘Enable Privilege Escalation’ option in the Ansible Tower UI, this will occur. In Ansible Tower, we may need to enter the password twice.

8

Here is anohter mtheod to deal with the ansible error missing sudo password error:

fatal: [node]: FAILED! => {"msg": "Missing sudo password"}Copy Code

Despite the fact that the user already existed in the sudoers file on the remote host to conduct commands without the requirement of a password, this warning will still be displayed. In this case insert the following in the main YAML playbook:

Also in the

/etc/ansible/ansible.cfg/Copy Code
enable the commented out or change the following:

 

Here, the entry

remote_tmp = /tmp/ansible-$USERCopy Code
avoids messages such as:

9

We can solve the ansible error missing sudo password in the following method:

The error is eliminated in this case by including the command

/bin/shCopy Code
in the line of
/etc/sudoersCopy Code
that allows commands to be executed without a password.

This was the error message:

Just one more thing:

user ALL= NOPASSWD: /usr/bin/id, /usr/bin/whoami, /bin/shCopy Code

For testing, we can also add the

idCopy Code
and
whoamiCopy Code
.

[Need assistance with similar queries? We are here to help]

Conclusion

To sum up we have gone through the Ansible missing Sudo password error. With the support of our Server management support services, we have also seen the steps to remove the error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!