Hello,
I have an inventory file with the same host twice, once using ssh on port 22, once using ssh on port 12345. This is inventory file bad.hosts2:
[host1]
foo.example.com:22 ansible_connection=ssh ansible_ssh_user=root
[host2]
foo.example.com:12345 ansible_connection=ssh ansible_ssh_user=root
The intent is to use one host (host1) to copy a new sshd config file and to setup sshd to run on a different port. From then on, the second host (host2) would be used.
However, the behavior is strange: no matter what I do, port 22 is used.
Johns-MacBook-Air:ansible.bug j$ ansible -i bad.hosts2 -m ping host1
foo.example.com| success >> {
“changed”: false,
“ping”: “pong”
}
Johns-MacBook-Air:ansible.bug j$ ansible -i bad.hosts2 -m ping host2
foo.example.com | success >> {
“changed”: false,
“ping”: “pong”
}
Note sshd is only running on port 22, and if I switch the order of the two hosts in the inventory file, both host1 and host2 will fail the ping.
What is happening here?
Thanks
John