# Mutliple inventories, group\_vars and empty group issues

**URL:** <https://forum.ansible.com/t/mutliple-inventories-group-vars-and-empty-group-issues/28094>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [July 19, 2018, 2:12pm UTC](https://forum.ansible.com/t/mutliple-inventories-group-vars-and-empty-group-issues/28094 "2018-07-19T14:12:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_G](https://avatars.discourse-cdn.com/v4/letter/v/49beb7/32.png) [@Vincent\_G](https://forum.ansible.com/u/Vincent_G)\
**Post date:** [July 19, 2018, 2:12pm UTC](https://forum.ansible.com/t/mutliple-inventories-group-vars-and-empty-group-issues/28094/1 "2018-07-19T14:12:11Z")

</div>

Hi there,

Got an issue with AWX 1.0.6.14 / ansible 2.5.4

First let me explain the directory and ini structure :

```auto
inventory/core/core.ini
inventory/core/group_vars/all/all.yml
inventory/core/group_vars/core/core.yml
inventory/core/group_vars/dns/dns.yml
inventory/core/host_vars/dns1
inventory/core/host_vars/dns2
inventory/dc01/dc01.ini
inventory/dc01/group_vars/dc01/dc01.yml
inventory/dynamic/dynamic.sh

```

The content of core.ini is to define hosts into groups that must be deployed to different locations (dc01, dc02…)

```auto
[core:children]
dns

[dns]
dns1
dns2

```

dc01.ini creates a mapping of core hosts to the defined dc01 group and a declaration of an empty group that is filled by the dynamic inventory script (not declaring it throws an error) :

```auto
[dc01:children]
core
products

[products]
#(empty)

```

Last is a dynamic inventory script that outputs a json like :

```auto
{"_meta": {"hostvars": {"product01": {"ansible_host": "10.0.1.181"}, "product02": {"ansible_host": "10.0.1.182"}}}, "products": {"hosts": ["product01", "product02"]}}

```

When running `ansible-playbook -i inventory/core/core.ini -i inventory/dc01/dc01.ini -i inventory/dynamic/dynamic.sh playbook/playbook.yml` from the command line, we get the expected result : ansible has computed the inventories and produced a merged one with the correct hierarchy and group\_vars mapping

But when running the same on AWX, the dc01 group\_vars are not parsed/available to the `products` hosts

We created an inventory on AWX with the ini files and dynamic.sh (all from SCM).

I’ve seen many issues on both github/awx and github/ansible but need help to leverage the issue the time the fixes will show up.  
Most of them are closed but I don’t which one(s) our issue applies as we match most of the use cases !

- [Inventory group vars are not loaded](https://github.com/ansible/awx/issues/761)
- [Target multiple inventories for a job template](https://github.com/ansible/awx/issues/412)
- [Stop forcing overwrite\_vars=True for SCM inventory sources](https://github.com/ansible/awx/issues/1271)
- [SCM group\_vars not added to non-SCM additional hosts](https://github.com/ansible/awx/issues/1647)
- [Empty groups ignored when sourcing from projects](https://github.com/ansible/awx/issues/1966)
- [New ansible-inventory option to return variables at group level](https://github.com/ansible/ansible/issues/30877)
- [Empty groups from vars plugins inconsistently shown](https://github.com/ansible/ansible/issues/36177)

Any help or indications welcome 🙂

Best regards,

---

<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:** [August 1, 2018, 7:24pm UTC](https://forum.ansible.com/t/mutliple-inventories-group-vars-and-empty-group-issues/28094/2 "2018-08-01T19:24:56Z")

</div>

Instead of ansible-playbook to recreate how AWX generates the host vars; try using ansible-inventory to see what the outcome is.

---

<div class="post-metadata">

**Author:** ![Vincent\_G](https://avatars.discourse-cdn.com/v4/letter/v/49beb7/32.png) [@Vincent\_G](https://forum.ansible.com/u/Vincent_G)\
**Post date:** [August 2, 2018, 12:31pm UTC](https://forum.ansible.com/t/mutliple-inventories-group-vars-and-empty-group-issues/28094/3 "2018-08-02T12:31:42Z")

</div>

Hi,

Just a follow up.

We end up using a custom script that simply calls :  
`ansible-inventory --list --export -i inventory/core/core.ini -i inventory/dc01/dc01.ini -i inventory/dynamic/dynamic.sh`

We found some ungrouped things (into var/ungrouped, we saw the inventory script itself for exemple). We had to filter out those entries thanks to a pipe and jq : `| jq "del(.ungrouped)"`

After declaring this script into AWX, the mapping is fine.

Drawback : it is not so dynamic as we needed to duplicate/update the script for each dc.ini

But its a good workaround (as it works/parse/merge as expected !)

Regards,
