Multiple inventory sources

78 views
Skip to first unread message

Thomas Quinot

unread,
Nov 17, 2014, 12:05:48 PM11/17/14
to ansible...@googlegroups.com
Redirecting from -devel as advised.

On Fri, Nov 14, 2014 at 6:19 AM, Thomas Quinot <tho...@quinot.org> wrote:

> As far as I understand the current state of source code, ansible_hosts
> can be:
> * the path to a dynamic inventory program
> * the path to a static inventory file
> * the path to an inventory directory, from which dynamic inventory
> scripts and static inventory files are launched
> * a comma-separated list of host names
>
> In my usage context, several distinct applications are managed through
> Ansible, each with its own subset of hosts, and its own host grouping
> needs. So, I would like to have a two-level inventoy with:
> * a shared, company one inventory listing all hosts and setting
> common host variables
> * AND an application specific inventory for each application,
> providing additional application specific host groups (and
> possibly variables).
>
> I think it would be possible to implement that with minimal fuss
> by minimally tweaking the semantics of ansible_hosts so that it could
> be:
>
> * the path to a dynamic inventory program
> * the path to a static inventory file
> * the path to an inventory directory, from which dynamic inventory
> scripts and static inventory files are launched
> * a host name
> OR * a comma-separated list of /any of the above/
>
> I could thus set in a shared configuration:
>
> ansible_hosts=/path/to/companywide/inventory,appspecific_inventory
>
> where /path/to/companywide/inventory would be the company-wide
> shared inventory, and "appspecific_inventory", being a relative path,
> would be interpreted relative to the current directory and contain the
> application specific data.
>
> Thoughts?

(Again, I'm willing to start work on the implementation if there is
interest in this feature. :) ).

Thomas.

Michael DeHaan

unread,
Nov 17, 2014, 3:19:01 PM11/17/14
to ansible...@googlegroups.com
I don't think as inventory directories are an existing thing.

That being said, any alternative way of managing inventory you want can be built using an inventory script.




Thomas.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20141114210040.GC98767%40melamine.cuivre.fr.eu.org.
For more options, visit https://groups.google.com/d/optout.

Thomas Quinot

unread,
Nov 18, 2014, 4:57:57 AM11/18/14
to ansible...@googlegroups.com
* Michael DeHaan, 2014-11-17 :

> I don't think as inventory directories are an existing thing.

Not sure what you mean, as far as I can tell this is supported
by ansible.inventory.dir, and documented under "Using Multiple Inventory
Sources".

> That being said, any alternative way of managing inventory you want can be
> built using an inventory script.

That's true, but would require reimplementing the parsing of standard
inventoy files in the dynamic inventory script.

Thomas.

Serge van Ginderachter

unread,
Nov 18, 2014, 6:05:35 AM11/18/14
to ansible...@googlegroups.com

On 18 November 2014 10:57, Thomas Quinot <tho...@quinot.org> wrote:
That's true, but would require reimplementing the parsing of standard
inventoy files in the dynamic inventory script.


​Not reinventing, you van just import the ansible.inventory​ in your script and use it (on your specific paths.)

E.g. this example script dumps the whole inventory in a dynamic script compatible json:

https://github.com/ginsys/ansible-plugins/blob/devel/bin/ansible-inventory

Reply all
Reply to author
Forward
0 new messages