# Config Files for Inventory Scripts

**URL:** <https://forum.ansible.com/t/config-files-for-inventory-scripts/16720>\
**Category:** Ansible Developer\
**Created:** [November 7, 2014, 3:59pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720 "2014-11-07T15:59:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 7, 2014, 3:59pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720/1 "2014-11-07T15:59:49Z")

</div>

Howdy everyone,

I have a question around config files for inventory scripts.

So far there are several inventory scripts that also include config files which are individually contained.

I am currently working on adding a configuration file for rax.py and have chosen to just use ansible.cfg and the functionality provided in ansible.constants by importing it into my inventory script.

Is this an OK thing to do? Or would it be preferble to keep away from this?

In this case, I am using a config header of [rax].

I could easily still use get\_config from ansible.cfg for config/env var/defaults and just specify another config file, but I don’t want to keep the config file next to the script, because this causes some issues when using an inventory dir with multiple files.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 7, 2014, 4:22pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720/2 "2014-11-07T16:22:40Z")

</div>

it seems looking for a config file in the os.path.basename of argv[0] for the inventory script is a reasonable approach.

I don’t think we should have inventory script settings in ansible.cfg because ansible.cfg contains a lot of examples about the core program, but inventory scripts are plugins, and don’t currently ship with ansible (though I think they should, in something like /usr/share at least)

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 7, 2014, 4:45pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720/3 "2014-11-07T16:45:55Z")

</div>

Yeah, I am “against” looking for a config in os.path.basename because when you have an inventory directory, that has a script and a config in it, pointing ansible to that directory, will result in ansible trying to parse the config as an inventory file.

I’d like to have a set of places similar to ansible.cfg where the config file would go. It just seemed that instead of requiring yet another config file, since with pyrax you could potentially have, using ansible.cfg would/could be appropriate:

ansible.cfg  
~/.rackspace\_cloud\_credentials  
~/.pyrax.cfg

Adding another config file seems a terrible idea, and I’d like to keep the ansible stuff out of the pyrax config files since they aren’t really for pyrax.

If I don’t use ansible.cfg, I’ll likely have to revert to duplicating the code to find ansible.cfg, use os.path.basename on the found ansible.cfg, or requiring an ENV var to specify the location of the config file.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 7, 2014, 4:52pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720/4 "2014-11-07T16:52:41Z")

</div>

Ansible is set to ignore files ending in “.ini” in directories, so this may help with that specific problem.

You could also have something like RAX\_INVENTORY\_CFG to specify alternative paths.

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [November 7, 2014, 5:03pm UTC](https://forum.ansible.com/t/config-files-for-inventory-scripts/16720/5 "2014-11-07T17:03:01Z")

</div>

What he said ↓ (default to INI in the same directory but have an  
environment variable that can be used to specify an alternate path).
