# Multiple values for 'inventory = x' in ansible.cfg

**URL:** <https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901>\
**Category:** Get Help\
**Created:** [June 9, 2026, 7:57pm UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901 "2026-06-09T19:57:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [June 9, 2026, 7:57pm UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901/1 "2026-06-09T19:57:21Z")

</div>

I have `inventory = ../inventories` in my `ansible.cfg`. This finds all possible inventory files (static as well as dynamic ones) inside the directory `../inventories’.

Now I want to extend this a bit and add a subdirectory of `../inventories` where a `main.yml` serves as _first point of contact_, so to say

```bash
../inventories
         |-- silena.py
         |-- another_inventory.yml
         |-- patroni/
                  |-- main.yml
                  |-- test1.yml
                  |-- test2.yml

```

how can I append this to my `inventory = ../inventories` entry in order to also catch the entire patroni structure?

I failed with

- `inventory = ../inventories:../inventories/patroni`
- `inventory = ../inventories/*`

so far

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [June 9, 2026, 8:51pm UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901/2 "2026-06-09T20:51:54Z")

</div>

Just use a comma:

```auto
inventory = ../inventories/patroni,../inventories

```

But I’m a little confused. If you specify `inventory = ../inventories`, it will pull in all the files, including from the `patroni` subdirectory. (I think you know that already.)

What’s confusing me is, what do you expect to be the final result, and in what way would it be different if it parsed `inventories/patroni/main.yml` before any others?

Edit: I’ll go a step farther and say — having thought of no use case for this — that if you’re building in differences that depend on the order these inventories are parsed, you should reconsider.

Furthermore, in my tests, although the above configuration did cause the `../inventories/patroni/main.yml` to be parsed first, _that same inventory file was parsed a second time_ when the `../inventories` tree was traversed. Run `ansible-inventory` with lots of "v"s and grep for `^Parse` to see the parsing order.

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [June 10, 2026, 7:20am UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901/3 "2026-06-10T07:20:07Z")

</div>

> [@utoddl](#):
>
> But I’m a little confused. If you specify `inventory = ../inventories`, it will pull in all the files, including from the `patroni` subdirectory. (I think you know that already.)

actually I wasn’t sure it extends to subdirectories also.

Maybe I just have a connection problem with one of the dynamic inventories and due to that it never arrives at the subdirectory inventory and just hangs. Will have to verify that later and report back.

* * *

**EDIT:**

it is exactly as you suggested. The structure in the subdirectory workes without a specific mentioning.

It was just the missing connectivity on my dev machine with the source of a dynamic inventory on the higher level, that made it seem not to work on first sight.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [June 10, 2026, 10:49am UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901/4 "2026-06-10T10:49:06Z")

</div>

We had a similar problem where an inventory script took minutes to run — far too long to run on each `ansible-*` invocation. Our solution was to periodically cache a copy of that inventory and use the cache. That worked because that inventory wasn’t very dynamic. We later dropped it entirely with a coincident data center migration. (Yay!)

---

<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:** [July 10, 2026, 10:49am UTC](https://forum.ansible.com/t/multiple-values-for-inventory-x-in-ansible-cfg/45901/5 "2026-07-10T10:49:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
