Ansible: sudo without password

Question:

I want to run ansible with user sa1 without sudo password:

First time OK:

Second time FAILED:

Please help!

Answer:

It’s not ansible it’s your server’s configuration. Make sure that sudo is allowed for the user ansible is using without password.

  1. To do that login to the server
  2. Open the sudoers file with sudo visudo
  3. Make sure you have a line something like this: centos ALL=(ALL) NOPASSWD:ALL
  4. Replace centos with the your user
  5. Save the file

You can try from the server itself by running:

If this works it should work from ansible too.

Leave a Reply