Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible playbook failed: Timeout (12s) waiting for privilege escalation prompt: "}

Tags:

ansible

I'm trying to automate some of my manual tasks on a VM. As part of that my VM doesn't have direct root access. So I've to use a different user and then escalate to root. When I try to switch to root user, the password prompt is different than the default prompt. The prompt I see is as shown below

================== [user1@vm-1 tmp]$ su - root

Enter login password:

I wrote a playbook to test the connectivity. The play looks as below

=====================================

 hosts: vm-1
 any_errors_fatal: true
 become: true
 become_method: su
 become_user: root
 gather_facts: no
 vars:
 ansible_become_pass: "r00t"
 tasks:
 name: Test me
 command: 'echo works'

=====================================

My host file looks as below

localhost ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
vm-1 ansible_ssh_host=1.2.3.4 
ansible_connection=ssh 
ansible_ssh_user=user1 
ansible_ssh_pass=password  
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'

=====================================

With this config, when I try to run the play, I'm getting below error

fatal: [vm-1]: FAILED! => {"msg": "Timeout (12s) waiting for privilege escalation prompt: "}

The same playbook works on a different VM but the prompt while trying to switch user to root is simply "Passowrd"

Appreciate your help on this.

By the way I tried this in ansible 2.4, 2.5 versions. In both the releases I got the same error.

Thanks in advance. Ramu

like image 476
Ramu Akula Avatar asked Jul 30 '18 16:07

Ramu Akula


1 Answers

I had difficulties tracking down an open ticket but here is one that is closed and has some workarounds and some solutions that may or may not work for you: https://github.com/ansible/ansible/issues/14426

I have had at least two machines where none of the listed solutions work. It also slows down a direct SSH without Ansible and a reboot does not work. I was unable to figure out the issue so now I just rebuild the machine.

As @AHT said, you could just increase the timeout to 30 seconds in ansible.cfg, however, I think this should only be temporary being it is masking the bigger issue.

like image 188
Aaron Walker Avatar answered Nov 02 '22 13:11

Aaron Walker