I'm new to ansible but are having basic issues reaching multiple hosts via ansible. I'm able to reach all hosts via ssh and also if I use ansible to target any specific host in my inventory. It successfully reaches one of my hosts but fails all the others.
If I run:
ansible all -i inventory.yml -u oytal -m ping
It returns:
192.168.1.90 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
192.168.1.21 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).",
"unreachable": true
}
192.168.1.20 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).",
"unreachable": true
}
192.168.1.100 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).",
"unreachable": true
}
It's not consistent which host is unreachable, I shifted around the order of my hosts and even removed the successful one, and it will reach one of the others instead but still fail the rest.
My inventory:
---
all:
hosts:
192.168.1.90:
192.168.1.21:
192.168.1.20:
192.168.1.100:
ssh [email protected]
can connect andansible ... -u oytal
can't. This would suggest some kind of SSH keys misconfiguration i.e. Ansible and SSH utilities are configured to use different keys (and not all public keys are stored in authorized_keys at remote hosts).