我有这本剧本:
---
- hosts: all
become: yes
become_user: root
gather_facts: no
pre_tasks:
- name: 'install python2'
raw: sudo apt-get -y install python-simplejson
roles:
- git
...
有时,它工作得非常好,有时会给我这个错误:
==> default: Running provisioner: ansible...
default: Running ansible-playbook...
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i '/var/www/test/.vagrant/machines/default/virtualbox/private_key' -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --extra-vars="ansible_ssh_user='ubuntu'" --limit="all" --inventory-file=ansible/hosts/hosts_linux.txt -v ansible/site.yml
Using /etc/ansible/ansible.cfg as config file
PLAY ***************************************************************************
TASK [install python2] *********************************************************
fatal: [10.0.11.44]: FAILED! => {"changed": false, "failed": true, "rc": 255, "stderr": "", "stdout": "", "stdout_lines": []}
PLAY RECAP *********************************************************************
10.0.11.44 : ok=0 changed=0 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
我想知道为什么我会收到此错误,这是什么意思?错误没有输出,如果我多次尝试,完全相同的代码可以正常工作。这没有道理。为什么ansible无法安装python?
答案 0 :(得分:0)
根据你的评论,问题在于ssh。您可以在当前工作目录中创建自己的ansible.cfg文件,并直接提供openssh选项,如下所述:open-ssh options
我建议你试试:
[defaults]
host_key_checking = False
此外,在您的Playbook运行期间,您可以手动指定要使用的ssh密钥:
ansible-playbook --private-key /path/to/ssh_key ...
最后,请确保没有IP冲突,因为您的服务器的ssh指纹不应更改。尝试手动ssh几次。