Ansible Engine shows Authentication Failure on localhost for ad-hoc command

Latest response

This is for Ansible Engine 2.7.0. I'm trying to understand why I'm getting this message when I run

ansible all -m ping

localhost | UNREACHABLE! => {
     "changed": false,
     "msg": "Failed to connect to the host via ssh:  ssh:  connect to host localhost port 22:  No route to host\r\n",
}
192.168.20.21 | SUCCESS => {
     "changed": false,
     "ping": "pong"
}

I'm new to Ansible, using demo software in our development environment, so we don't currently have support for it. However from a RHEL VM that has Ansible 2.7.0 Engine installed on it, I'm trying to understand why I'm getting the following error message when I run a basic Ansible ad-hoc command:

ansible all -m ping

localhost | UNREACHABLE! => {
     "changed": false,
     "msg": "Failed to connect to the host via ssh:  ssh:  connect to host localhost port 22:  No route to host\r\n",
}
192.168.20.21 | SUCCESS => {
     "changed": false,
     "ping": "pong"
}

For some reason, getting an error message on the localhost, however get the correct return response from a remote RHEL VM.

Now I'm running this command as Oracle user, which is a service account. I've exchanged ssh keys between the two servers with no issues. I have a group called Ansible and Oracle is in the Ansible group:

cat /etc/group | grep -i 'oracle'
ansible:x:1001:oracle

My entries under /etc/ansible/hosts look like the following:

[local]
localhost
#192.168.20.22  ansible_ssh_pass=oracle  ansible_ssh_user=oracle

[oracle12c]
192.168.20.21  ansible_ssh_pass=oracle  ansible_ssh_user=oracle

And my /etc/hosts has the following entries

127.0.0.1  localhost  localhost.localdomain  localhost4  localhost4.localdomain4
::1        localhost  localhost.localdomain  localhost6  localhost6.localdomain6

192.168.20.21  redacted  hostname
192.168.20.22  redacted  hostname

Responses