# using host\_vars and variables

**URL:** <https://forum.ansible.com/t/using-host-vars-and-variables/33800>\
**Category:** Ansible Project\
**Created:** [September 13, 2020, 9:43pm UTC](https://forum.ansible.com/t/using-host-vars-and-variables/33800 "2020-09-13T21:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johana\_Galarza\_Monta](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@Johana\_Galarza\_Monta](https://forum.ansible.com/u/Johana_Galarza_Monta)\
**Post date:** [September 13, 2020, 9:43pm UTC](https://forum.ansible.com/t/using-host-vars-and-variables/33800/1 "2020-09-13T21:43:01Z")

</div>

I am trying to use the following configuration in hosts.yml

all:  
hosts:  
177.177.188.199:  
177.177.188.200:  
vars:

ansible\_connection= {{ ansible\_conn }}  
ansible\_user= {{ ansible\_usr }}  
ansible\_ssh\_common\_args= {{ common\_args }}

and I am having two problems:

1. No inventory was parsed, only implicit localhost is available  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost  
does not match ‘all’

Which is weird because in the playbook I used `all`

It does work when I used INI

[all]  
177.177.188.199 ansible\_connection=“{{ ansible\_conn }}” ansible\_user=“{{ ansible\_usr }}” ansible\_ssh\_common\_args=“{{ common\_args }}”

1. When I use the variables in INI common\_args is not found. I declared these in host\_vars

ansible\_conn: ssh  
ansible\_usr: user  
common\_args: ‘-o ProxyCommand=“ssh -W %h:%p -q user@vpn”’

And it cannot solve the `common_args` I wrote them with ’ and with "

Does anyone understand how to make the host.yml? and why the proxy declared in variables doesnt work

Thanks  
Jacque

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 14, 2020, 12:22am UTC](https://forum.ansible.com/t/using-host-vars-and-variables/33800/2 "2020-09-14T00:22:55Z")

</div>

Fix the syntax.

&nbsp;&nbsp;all:  
&nbsp;&nbsp;&nbsp;&nbsp;hosts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;177.177.188.199:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;177.177.188.200:  
&nbsp;&nbsp;&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ansible\_connection: "{{ ansible\_conn }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ansible\_user: "{{ ansible\_usr }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ansible\_ssh\_common\_args: "{{ common\_args }}"
