Ansible version 2.1
I have an inventory file hosts
[nodes]
host1
host2
...
And a simple playbook site.yml
---
- hosts: all
tasks:
- include: tasks/main.yml
If I just start the play,
ansible-playbook -i hosts site.yml -vvvv
I get this error for all hosts,
ESTABLISH SSH CONNECTION FOR USER: None
fatal: [host1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
...
However, reading Ansible Inventory doc, I added ansible_user
to the hosts
file,
[nodes]
host1 ansible_user=root
host2 ansible_user=root
...
This solves the SSH CONNECTION UNREACHABLE
error. However, do I have to add ansible_user=root
next to all the hosts? Or is there a simpler way to do this?