Dynamic Groups In Custom Dynamic Inventory

29 views
Skip to first unread message

Gabriel Forster

unread,
Nov 3, 2017, 1:45:06 PM11/3/17
to Ansible Project
I have a custom dynamic inventory whose source data is basically a custom flat-file database that consists of a hostname and a bunch of key=value pairs. In the dynamic inventory, I'm using those key=value pairs as hostvars.  I currently do not have any defined groups.

What I would like to do is create groups on the fly using the hostvars. e.g. If I want to run a playbook against all of the hosts in the dynamic inventory with key=value pair of production=false, then run that same playbook against all those with production=true, then run it against production=true and platform=linux, etc.

I don't think I should have to create a separate playbook for all of those, maybe I do. I would think there is a way to do that via command-line arguments or somesuch. I just can't find any straightforward documentation concerning that.


Thanks

Brian Coca

unread,
Nov 3, 2017, 6:10:09 PM11/3/17
to Ansible Project
This might be what you want.

http://docs.ansible.com/ansible/devel/plugins/inventory/constructed.html



--
----------
Brian Coca

Gabriel Forster

unread,
Nov 6, 2017, 12:27:20 PM11/6/17
to Ansible Project
This looks like the right idea...Just need to figure out how to get it working.
Reply all
Reply to author
Forward
0 new messages