4

hello everyone i have a problem which is , i can't run an ansible playbook from aws instance (ansible system) to another aws (docker system) instance

it shows me this error

fatal: [x.x.x.x]: FAILED! => {"msg": "Missing sudo password"} 

can any one help me please , i will be grateful

BMW
  • 42,880
  • 12
  • 99
  • 116
love coding
  • 59
  • 1
  • 1
  • 4
  • 3
    Your problem is that you (pick one or more) did not provide a password for sudo / did not install/configure sudo correctly on the target / did not configure your inventory correctly to access your target. You can start by providing the sudo password on the command line using the `--ask-become-pass` option to `ansible[-playbook]`. This should get you going before you take the appropriate actions [after reading the doc](https://docs.ansible.com/ansible/latest/user_guide/become.html). – Zeitounator Nov 26 '19 at 08:18

3 Answers3

8

From: Missing sudo password in Ansible

You should give ansible-playbook the flag to prompt for privilege escalation password.

ansible-playbook --ask-become-pass
Dan Pratt
  • 126
  • 1
  • 5
-1

add the user into visudo file on the host server some thing like this

{username} ALL=(ALL)       NOPASSWD: ALL
Ammy
  • 369
  • 2
  • 8
-2

Actually i didn't get your scenario very well,do you want to connect to docker container from your playbook?

if that is the case you can add ssh public key 'id_rsa.pub' (generate this file by the command ssh-keygen inside the instance from where you want to connect to docker) to authorized_keys file inside docker container. When shh keys are there you don't need a sudo password.

You can do this in either in Dockerfile or using ssh-copy-id

if you are not using ssh, and having this error while running task with 'become: true' or 'become: sudo', then add the following line to /etc/sudoers list

<username> ALL=NOPASSWD: ALL
Sruthi CP
  • 341
  • 3
  • 13
  • The connection to the host is actually ok. The problem is with privilege escalation: `sudo` is requiring a password – Zeitounator Nov 26 '19 at 08:18