# Variables About Other Hosts

**URL:** <https://forum.ansible.com/t/variables-about-other-hosts/18632>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [June 29, 2015, 7:59am UTC](https://forum.ansible.com/t/variables-about-other-hosts/18632 "2015-06-29T07:59:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul\_SEVILLA\_CANAVAT](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@Raul\_SEVILLA\_CANAVAT](https://forum.ansible.com/u/Raul_SEVILLA_CANAVAT)\
**Post date:** [June 29, 2015, 7:59am UTC](https://forum.ansible.com/t/variables-about-other-hosts/18632/1 "2015-06-29T07:59:24Z")

</div>

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:

```auto
cat /etc/hosts
[test1]
test1
[test2]
test2

```

My SSH configuration:

```auto
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?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 2, 2015, 9:41pm UTC](https://forum.ansible.com/t/variables-about-other-hosts/18632/2 "2015-07-02T21:41:32Z")

</div>

soo .. you should really not overwrite /etc/hosts to make it your  
inventory, this might break many things in your system, by default  
ansible uses /etc/ansible/hosts which should not affect anything else.

what vars are you expecting? where are they defined?
