Hi,
playbook is
- hosts: servers
remote_user: ubuntu
become: yes
become_user: root
become_method: sudo
tasks:
- name: Install tmux
apt: name=tmux state=present
error:fatal: [192.168.80.129]: FAILED! => {“changed”: false, “failed”: true, “module_stderr”: “Shared connection to 192.168.80.129 closed.\r\n”, “module_stdout”: “sudo: a password is required\r\n”, “msg”: “MODULE FAILURE”, “rc”: 1}
Thanks
Hello
The reason for the failure is that the playbook is not able to retrieve the credentials for Ubuntu user to become root. In order to resolve this you will have to use --ask-sudo-pass suffix everytime you execute an ansible-palybook command. Else you may make an entry in ansible.cfg to set ask_pass : TRUE using either of the below options. This will prompt playbook to explicitly ask for sudo credentials every time at run time:
[OPTION-1] : Add below lines to defaults in ansible.cfg.
[defaults]
sudo_user = root
ask_pass = True
[OPTION-2] : Run below export command.
export ANSIBLE_ASK_SUDO_PASS=true
Thanks