问题描述
我无法在AWS实例上运行Ansible剧本.这是我的版本:
I'm having trouble running my Ansible playbook on AWS instance. Here is my version:
$ ansible --version
ansible 2.0.0.2
我创建的清单文件为:
[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"
}
现在在此清单上运行我的剧本时,出现如下错误Timeout (12s) waiting for privilege escalation prompt
:
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
如果我使用.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
作为清单参数运行相同的剧本,则它可以完美地在我的Vagrant实例上运行.(我相信,证明剧本/角色本身没有错)
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)
此外,如果我使用-vvvv
运行它,则复制exec ssh
行并手动运行它确实可以毫无问题地连接到AWS.
Also, if I run it with an -vvvv
, copy the exec ssh
line and run it manually it indeed connects to AWS without problems.
是否需要在清单文件中添加其他任何参数以连接EC2实例?我想念什么?
Do I need to add any other parameter on my inventory file to connect an EC2 instance? What am I missing?
推荐答案
关于此错误的git问题影响了此处 https://github.com/ansible/ansible/issues/13278#issuecomment-216307695
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
我的解决方案只是将timeout=30
添加到/etc/ansible/ansible.cfg
.
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).
这篇关于Ansible超时(12s)等待特权升级提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!