# Inventories sourced from a project - no group\_vars?

**URL:** <https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [January 10, 2018, 5:14pm UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453 "2018-01-10T17:14:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobby\_Brockway](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@Bobby\_Brockway](https://forum.ansible.com/u/Bobby_Brockway)\
**Post date:** [January 10, 2018, 5:14pm UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453/1 "2018-01-10T17:14:30Z")

</div>

Hi all,

I’d like to use the “Sourced from a Project” feature of the inventories but I’ve found that it doesn’t import any of my host\_vars or group\_vars with my project set up as it is:

`project/ group_vars/ dev.yml host_vars/ hostname.yml inventories/ dev.ini`

This was logged [here](https://github.com/ansible/awx/issues/761) but was regarding Tower rather than awx so was closed. Is there a certain way you have to layout the project to get this to work or is it just unsupported at the moment?

Using awx 1.0.2 commit ae06cff and awx\_web/awx\_task 1.0.2.337

Thanks,

Bobby

---

<div class="post-metadata">

**Author:** ![Chris\_Church](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Chris\_Church](https://forum.ansible.com/u/Chris_Church)\
**Post date:** [January 11, 2018, 5:15am UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453/2 "2018-01-11T05:15:02Z")

</div>

Hi Bobby,

In your case, it looks like group\_vars and host\_vars are adjacent to the project but not to the inventory file. If you want those variables imported, you would need to either:

- move group\_vars/host\_vars inside the inventories directory and specify the dev.ini file as your inventory source

- specify the inventories directory as your inventory source (though AWX doesn’t currently appear to detect a directory as a possible inventory source).

In their current location, group\_vars/host\_vars still work if you run ansible directory, because ansible itself loads group/host variables from the inventory as well as the project (see [http://docs.ansible.com/ansible/latest/playbooks\_variables.html#variable-precedence-where-should-i-put-a-variable](http://docs.ansible.com/ansible/latest/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable)).

You can run either of the following to see which variables AWX should import for a given inventory source:

- ansible-inventory -i inventories --list
- ansible-inventory -i inventories/dev.ini --list

---

<div class="post-metadata">

**Author:** ![Bobby\_Brockway](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@Bobby\_Brockway](https://forum.ansible.com/u/Bobby_Brockway)\
**Post date:** [January 11, 2018, 11:11am UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453/3 "2018-01-11T11:11:58Z")

</div>

Hi Chris,

I moved both group\_vars/ and host\_vars/ into inventories/ and awx is now picking up the host\_vars but still not the group\_vars. Here’s how it’s currently set up (using one dev host as an example):

`project/ inventories/ group_vars/ dev.yml host_vars/ hostname.yml dev.ini`

dev.ini:

`  
[loader]  
hostname

[dev:children]  
loader  
`

I ran the ansible-inventory -i inventories/dev.ini --list command and it does display all group\_vars and host\_vars but AWX doesn’t pull them in.

---

<div class="post-metadata">

**Author:** ![Bobby\_Brockway](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@Bobby\_Brockway](https://forum.ansible.com/u/Bobby_Brockway)\
**Post date:** [January 11, 2018, 11:38am UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453/4 "2018-01-11T11:38:11Z")

</div>

Actually there’s something much weirder going on here. Will test and raise a bug on GitHub and post link here.

---

<div class="post-metadata">

**Author:** ![Christopher\_Meyers](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Christopher\_Meyers](https://forum.ansible.com/u/Christopher_Meyers)\
**Post date:** [January 11, 2018, 1:59pm UTC](https://forum.ansible.com/t/inventories-sourced-from-a-project-no-group-vars/26453/5 "2018-01-11T13:59:24Z")

</div>

AWX relies on ansible-inventory to generate inventory. ansible-inventory, currently, applies group\_vars to the respective hosts and only outputs host\_vars. Example behavior [https://github.com/chrismeyersfsu/ansible-examples/tree/master/ansible-inventory](https://github.com/chrismeyersfsu/ansible-examples/tree/master/ansible-inventory)  
If you run the make target in there with ansible 2.4.2.x you get the following:

ansible-inventory -i inventory --list  
{  
“\_meta”: {  
“hostvars”: {  
“starscream”: {  
“i\_am\_a\_decepticon\_group\_variable”: “i\_am\_a\_decepticon\_group\_variable\_value”,  
“i\_am\_a\_starscream\_host\_variable”: “i\_am\_a\_starscream\_host\_variable\_value”,  
“i\_am\_an\_explicit\_inventory\_host\_variable”: “i\_am\_an\_explicit\_inventory\_host\_variable\_value”  
}  
}  
},  
“all”: {  
“children”: [  
“decepticons”,  
“ungrouped”  
]  
},  
“decepticons”: {  
“hosts”: [  
“starscream”  
]  
},  
“ungrouped”: {}  
}

where i\_am\_a\_decepticon\_group\_variable is a groups variable, but, as you can see from the above, it is applied to the hostvars section. I’m checking with ansible core to see about changing ansible-inventory to allow for a flag to NOT apply group vars to host vars.
