I'm having trouble running my Ansible playbook on AWS instance. Here is my version:
$ ansible --version
ansible 2.0.0.2
I created an inventory file as:
[my_ec2_instance]
default ansible_host=MY_EC2_ADDRESS ansible_user='ubuntu' ansible_ssh_private_key_file='/home/MY_USER/MY_KEYS/MY_KEY.pem'
Testing connection to my server:
$ ansible -i provisioner/inventory my_ec2_instance -m ping
default | SUCCESS => {
"changed": false,
"ping": "pong"
}
Now when running my playbook on this inventory I get the error Timeout (12s) waiting for privilege escalation prompt
as follows:
$ ansible-playbook -i provisioner/inventory -l my_ec2_instance provisioner/playbook.yml
PLAY [Ubuntu14/Python3/Postgres/Nginx/Gunicorn/Django stack] *****
TASK [setup] *******************************************************************
fatal: [default]: FAILED! => {"failed": true, "msg": "ERROR! Timeout (12s) waiting for privilege escalation prompt: "}
NO MORE HOSTS LEFT *************************************************************
PLAY RECAP *********************************************************************
default : ok=0 changed=0 unreachable=0 failed=1
If I run the same playbook using the .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
as the inventory parameter it works perfectly on my Vagrant instance.(I believe, proving there is nothing wrong in the playbook/roles itself)
Also, if I run it with an -vvvv
, copy the exec ssh
line and run it manually it indeed connects to AWS without problems.
Do I need to add any other parameter on my inventory file to connect an EC2 instance? What am I missing?
I fixed this error for my system because I forgot I had altered the ansible config file:
Try commenting the priviledge parameters that could be trying to sudo to root.
like so:
The account I was trying to ssh as did not have permission to become root.
In my case, the root cause was an incorrect entry in /etc/hosts for the localhost, causing a 20s delay for any
sudo
command.Changed it to the correct hostname to fix it. No more delay for sudo/privileged commands.
Check if it is a problem with an old version of sudo at destination server. Some old sudo versions does not have the -n option ansible uses.
There is a git issue about this error that affect various versions of Ansible 2.x in here https://github.com/ansible/ansible/issues/13278#issuecomment-216307695
My solution was simply to add
timeout=30
to/etc/ansible/ansible.cfg
.This is not a "task" or "role" timeout and was enough to solve the error (I do have some roles/tasks that take much longer than that).
I am building secure VM images for AWS, QEMU and VBox on an isolated network, with limited DNS support. Increasing the SSH Timeout to 40 sec had limited effect in my situation.
I am using Packer v1.5.5, Ansible v2.9.2 and OpenSSH v7.4p1
My solution was to change the
UseDNS
parameter in/etc/ssh/ssd_config
tono
.I added the following lines in my RHEL/CentOS kickstart configuration, with great result.
I ran the command like follows & it works : command: