I am managing hosts in two different data centers. I get to the managed hosts via a jump host. There is a dedicated jump host for each data center. My inventory files look something like:
$ cat inventory-dc1
[all:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q [email protected]"'
[docker]
docker-1 ansible_host=192.168.1.1
docker-2 ansible_host=192.168.1.2
$ cat inventory-dc2
[all:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q [email protected]"'
[docker]
docker-1 ansible_host=192.168.1.1
docker-2 ansible_host=192.168.1.2
When I run a playbook with inventory-dc1
everything works as expected.
The problem manifests when I subsequently run a playbook with inventory-dc2
. Ansible connects to the hosts from inventory-dc1
instead of inventory-dc2
. I know that the managed hosts have the same IP addesses but they are accessed via different jump hosts.