Ansible become_user

Hi @KodeKloud Team,

Im facing “Missing sudo password” error while I run a playbook.

My requirement is that I connect to the target server using “My_user” id and then I want to sudo as " oracle" user in the playbook.

Below is how my inventory file looks like
++++++++++++++++++
<<server_name>> ansible_host=<> ansible_connection=ssh ansible_user=<<My_user>> ansible_ssh_pass=<>

Playbook has
++++++++++
hosts: All
become: yes
become_user: oracle

When i ping the inventory ,I get a success response but when i run the playbook which has to sudo as “oracle” user , it says " “Missing sudo password” though i provide the correct pwd.

Try with the option -kK . It will prompt for password.

$ ansible-playbook mail.yml -kK 
SSH password: 
BECOME password[defaults to SSH password]: 
  • -k, --ask-pass : ask for connection password
  • -K, --ask-become-pass : ask for privilege escalation password

Please refer to the discussion here:

When I try with -kK option, it gives me this error

FAILED! => {“ansible_facts”: {}, “changed”: false, “failed_modules”: {“setup”: {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “failed”: true, “module_stderr”: “Shared connection to *********** closed.\r\n”, “module_stdout”: “\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}}, “msg”: “The following modules failed to execute: setup\n”}