# Ansible scans all files under host\_vars when executing a playbook

**URL:** <https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648>\
**Category:** Ansible Project\
**Created:** [February 2, 2018, 6:06pm UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648 "2018-02-02T18:06:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carl\_Wainwright](https://avatars.discourse-cdn.com/v4/letter/c/8797f3/32.png) [@Carl\_Wainwright](https://forum.ansible.com/u/Carl_Wainwright)\
**Post date:** [February 2, 2018, 6:06pm UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648/1 "2018-02-02T18:06:22Z")

</div>

Greetings,

I trying to understand if my setup is correct or not given the subject matter.

When I run a playbook on a particular host and a host\_vars file for another host has a syntactical error the playbook execution fails because of the broken host\_vars file.

Here is my inventory file layout

`  
docker11\_s ansible\_host=172.28.5.12 ansible\_ssh\_user=ipasupport  
docker12\_s ansible\_host=172.28.5.14 ansible\_ssh\_user=ipasupport  
docker13\_s ansible\_host=172.28.5.15 ansible\_ssh\_user=ipasupport  
docker14\_s ansible\_host=172.28.5.17 ansible\_ssh\_user=ipasupport  
docker15\_s ansible\_host=172.28.5.18 ansible\_ssh\_user=ipasupport

docker21\_s ansible\_host=172.28.5.3 ansible\_ssh\_user=ipasupport  
docker22\_s ansible\_host=172.28.5.4 ansible\_ssh\_user=ipasupport  
docker23\_s ansible\_host=172.28.5.5 ansible\_ssh\_user=ipasupport  
docker24\_s ansible\_host=172.28.5.6 ansible\_ssh\_user=ipasupport

docker31\_s ansible\_host=172.28.5.13 ansible\_ssh\_user=ipasupport  
docker32\_s ansible\_host=172.28.5.16 ansible\_ssh\_user=ipasupport

mqtts-vdc20\_s ansible\_host=10.156.20.207 ansible\_ssh\_user=ipasupport  
mqtts-vdc21\_s ansible\_host=10.156.21.201 ansible\_ssh\_user=ipasupport  
mqtts-vdc22\_s ansible\_host=10.156.22.34 ansible\_ssh\_user=ipasupport  
mqtts-vdc23\_s ansible\_host=10.156.23.35 ansible\_ssh\_user=ipasupport

vdc60-vm1 ansible\_host=172.28.5.14 ansible\_ssh\_user=ipasupport  
vdc60-vm2 ansible\_host=172.28.5.15 ansible\_ssh\_user=ipasupport  
vdc60-vm3 ansible\_host=172.28.5.16 ansible\_ssh\_user=ipasupport

vdc30-vm1 ansible\_host=10.156.30.232 ansible\_ssh\_user=ipasupport  
vdc30-vm2 ansible\_host=10.156.30.233 ansible\_ssh\_user=ipasupport  
vdc30-vm3 ansible\_host=10.156.30.234 ansible\_ssh\_user=ipasupport

vdc34-vm1 ansible\_host=10.156.34.45 ansible\_ssh\_user=ipasupport  
vdc34-vm2 ansible\_host=10.156.34.46 ansible\_ssh\_user=ipasupport  
vdc34-vm3 ansible\_host=10.156.34.47 ansible\_ssh\_user=ipasupport

camdockein01\_s ansible\_host=10.255.248.14 ansible\_ssh\_user=ipasupport

vdc80\_s ansible\_host=172.29.32.136 ansible\_ssh\_user=ipasupport

[dockerengines\_laptop]  
vdc80\_s

[dockerengines\_taf]  
camdockein01\_s shortname=camdockein01

[dockerengines\_ptk2]  
docker11\_s shortname=docker11  
docker12\_s shortname=docker12  
docker13\_s shortname=docker13  
docker14\_s shortname=docker14  
docker15\_s shortname=docker15  
docker21\_s shortname=docker21  
docker22\_s shortname=docker22  
docker23\_s shortname=docker23  
docker24\_s shortname=docker24  
docker31\_s shortname=docker31  
docker32\_s shortname=docker32

[docker23]  
docker23\_s shortname=docker23

[vdc60]  
vdc60-vm1 shortname=vdc60  
vdc60-vm2 shortname=vdc60  
vdc60-vm3 shortname=vdc60

[vdc70]  
vdc70\_s shortname=vdc70

[vdc21]  
mqtts-vdc21\_s shortname=vdc21

[vdc30]  
vdc30-vm1 shortname=vdc30  
vdc30-vm2 shortname=vdc30  
vdc30-vm3 shortname=vdc30

[vdc34]  
vdc34-vm1 shortname=vdc34  
vdc34-vm2 shortname=vdc34  
vdc34-vm3 shortname=vdc34

[dockerengines\_rs]  
mqtts-vdc20\_s shortname=vdc20  
mqtts-vdc21\_s shortname=vdc21  
mqtts-vdc22\_s shortname=vdc22  
mqtts-vdc23\_s shortname=vdc23

[dockerengines:children]  
dockerengines\_ptk2  
dockerengines\_rs  
dockerengines\_taf  
vdc60  
vdc30  
vdc34  
dockerengines\_laptop  
`

The playbooks are executing using the host names only. The playbooks all start with

`

- hosts: dockerengines

`

Is this behavior normal or am I causing this by how my inventory/playbooks are defined?

Regards,  
Carl

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 4, 2018, 9:03am UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648/2 "2018-02-04T09:03:03Z")

</div>

> I trying to understand if my setup is correct or not given the subject  
> matter.
> 
> When I run a playbook on a particular host and a host\_vars file for another  
> host has a syntactical error the playbook execution fails because of the  
> broken host\_vars file.

\<snip /\>

> The playbooks are executing using the host names only. The playbooks all  
> start with
> 
> - hosts: dockerengines
> 
> Is this behavior normal or am I causing this by how my inventory/playbooks  
> are defined?

This is by design, Ansible will read all the files in the inventory that includes group\_vars and host\_vars.

---

<div class="post-metadata">

**Author:** ![Carl\_Wainwright](https://avatars.discourse-cdn.com/v4/letter/c/8797f3/32.png) [@Carl\_Wainwright](https://forum.ansible.com/u/Carl_Wainwright)\
**Post date:** [February 5, 2018, 3:11pm UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648/3 "2018-02-05T15:11:42Z")

</div>

Hi,

Do you know if there a way to sanity check updated group/host var files before I commit the changes to Git?

Regards,  
Carl

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 5, 2018, 4:08pm UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648/4 "2018-02-05T16:08:40Z")

</div>

I use this 1 liner.

python -c 'import yaml,sys;yaml.safe\_load(sys.stdin)' \< host\_vars/testhost.yml

---

<div class="post-metadata">

**Author:** ![Chris\_DiGiovanni](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@Chris\_DiGiovanni](https://forum.ansible.com/u/Chris_DiGiovanni)\
**Post date:** [February 5, 2018, 7:27pm UTC](https://forum.ansible.com/t/ansible-scans-all-files-under-host-vars-when-executing-a-playbook/26648/5 "2018-02-05T19:27:44Z")

</div>

You could also just run ansible-playbook -i {{inventory}} {{ some-playbook}} --syntax-check

- Chris
