当我针对本地主机启动我的剧本时,出现此错误。
TASK [setup] *******************************************************************
fatal: [127.0.0.1]: UNREACHABLE! => {"changed": false, "msg": "SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}
to retry, use: --limit @deploy-test-env.retry
PLAY RECAP *********************************************************************
127.0.0.1 : ok=0 changed=0 unreachable=1 failed=0
我的主机文件有这个配置:
[local]
127.0.0.1
问题是什么?
Thanks!
Ansible 默认情况下尝试通过 ssh 连接。对于本地主机,您应该将连接设置为local
.
您可以在调用 playbook 时定义它:
ansible-playbook playbook.yml --connection=local
在你的剧本中定义它:
- hosts: local
connection: local
或者,最好将其定义为 localhost/127.0.0.1 的主机变量。创建文件host_vars/127.0.0.1
相对于您的剧本的以下内容:
ansible_connection: local
您还可以将其添加为库存中的组变量:
[local]
127.0.0.1
[local:vars]
ansible_connection=local
或作为主机变量:
[local]
127.0.0.1 ansible_connection=local
See 文档中的行为参数 http://docs.ansible.com/ansible/intro_inventory.html#list-of-behavioral-inventory-parameters.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)