Ansible 2.1版
我有一个清单文件 hosts
[nodes]
host1
host2
...
和一个简单的剧本 site.yml
---
- hosts: all
tasks:
- include: tasks/main.yml
如果我刚开始玩,
ansible-playbook -i hosts site.yml -vvvv
我收到所有主机的错误消息,
ESTABLISH SSH CONNECTION FOR USER: None
fatal: [host1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
...
但是,在阅读Ansible库存文档后,我将其添加ansible_user
到了hosts
文件中,
[nodes]
host1 ansible_user=root
host2 ansible_user=root
...
这样可以解决SSH CONNECTION UNREACHABLE
错误。但是,是否必须ansible_user=root
在所有主机旁边添加?还是有更简单的方法来做到这一点?