I’m getting problems while trying to access variables from another host in my Ansible template.
I’m using a SSH proxycommand configuration to access ‘internal’ instances in EC2.
My inventory host file is like:
cat /etc/hosts
[test1]
test1
[test2]
test2
My SSH configuration:
Host test1
User ubuntu
IdentityFile /home/dev/.ssh/private-key
Hostname XX.XX.XX.XX
StrictHostKeyChecking no
Host test2
User ubuntu
IdentityFile /home/dev/.ssh/private-key
Hostname 10.0.1.10
ProxyCommand ssh -F /home/dev/thing/ssh_config -W %h:%p test1
StrictHostKeyChecking no
ControlMaster auto
ControlPath /home/dev/.ssh/tmp/%h_%p_%r
and my template is like:
{{ hostvars[‘test1’] }}
{{ hostvars[‘test2’] }}
The first line in the previous template gives me all host variables, but the second, only shows:
{‘inventory_hostname’: ‘test2’, ‘group_names’: [‘test2’], ‘inventory_hostname_short’: ‘test2’}
How do i fix it?