本文介绍了Ansible Timeout (12s) 等待提权提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AWS 实例上运行 Ansible playbook 时遇到问题.这是我的版本:

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"
}

现在,在此清单上运行我的剧本时,我收到错误 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 问题会影响 Ansible 2.x 的各个版本 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 Timeout (12s) 等待提权提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:13