Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Add Dynamic group intersections to inventory file #10131
I'd like to use group patterns to find the intersection of two dynamic groups, then make those groups the children of other groups. I've tested two methods and either get an error or no results. Method 1 from below is the most intuitive based on the documentation for patterns and dynamic inventory groups.
Steps To Reproduce:
hosts/ec2.py and hosts/ec2.ini: http://docs.ansible.com/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script
Method 2: Define one static group composed of intersection of two dynamic groups
This would be a great addition! I find almost all my deployments and provisions have intersections... Rather then do this in a customized dynamic hosts file, would love to see in static hosts file!
My recent questions about this are related to this. My need is to
On Friday, July 17, 2015, Andrew Sannier email@example.com wrote:
On 26 August 2015 at 20:27, MadGhigno firstname.lastname@example.org wrote:
I understand this is how Amazon stuff seems to work. To be honest, I never
Given, I do consider the ansible inventory to be the start of pretty much
Nice trick Brian.
So one approach would create a 'subgroups.yml' playbook that, when run, defines the dynamic intersection groups depending on the current state of your AWS account. We could then
From a modelling perspective, this highlights that your infrastructure is actually dynamic and not static as the
I think to get this to work with
Just want to update on Brian's trick, which I have gotten working for my
You specifically must not add predefined tag groups for the intersections
My working solution is a subgroups file with entries like so:
One entry like that for each desired subgroup, where
Just include this playbook at the top of a playbook that references your
On Thu, Sep 17, 2015 at 6:25 PM, Kal Hodgson email@example.com
On 30 September 2015 at 07:38, Andrew Sannier firstname.lastname@example.org
Thanks for the update Andrew.
I could not get
As I think more on it, empty "pre-defined subgroups" makes much less sense
I'll give your approach a big +1, being shorter and less confusing.
Switch to Proposal
As of April of 2016, we have started using the Ansible Proposal process for large feature ideas or changes in current functionality, such as this. Because this issue has been open for so long without any action, we are going to go ahead and close it at this time. If you are still interested in seeing this new feature get into Ansible, please submit a proposal for it using this process.
If you have any further questions, please let us know by stopping by our devel mailing list, or our devel IRC channel:
This problem has been something that has bugged me since picking up Ansible. I've monitored this thread, and was really disappointed when it was closed the way it was. (by the way, I could not get any of the described work arounds working. I'm pretty sure some of the snippets aren't even valid Ansible).
So, I solved it by realizing that dynamic inventory is just JSON consumed via stdin. So I wrote something that takes the output of another dynamic inventory file, reads in a custom static inventory file that allows usage of Ansible Patterns, and transforms the inventory JSON and outputs the result to stdout.
@mazubieta I understand your concerns, however the issue had not had any movement on it in almost a year (besides +1's). Moving it to a proposal is not rejecting the idea, it's asking for it to be moved to a format where the community can vote on it and (if it is accepted) to be placed on a schedule for implementation.
When originally writing this, I thought it will be easy to do the intersection between 'ovirt_metrics_hosts' and 'ovirt_up_hosts' in ansible itself. Appanrently that's not so easy, doing this here for now. See also: ansible/ansible#10131 Bug-Url: https://bugzilla.redhat.com/1405813 Change-Id: I3fa8d34f30fb553a298b4ff7d419c4ecfad7d61b Signed-off-by: Yedidyah Bar David <email@example.com>
When originally writing this, I thought it will be easy to do the intersection between 'ovirt_metrics_hosts' and 'ovirt_up_hosts' in ansible itself. Appanrently that's not so easy, doing this here for now. See also: ansible/ansible#10131 Bug-Url: https://bugzilla.redhat.com/1405813 Change-Id: I3fa8d34f30fb553a298b4ff7d419c4ecfad7d61b Signed-off-by: Yedidyah Bar David <firstname.lastname@example.org> (cherry picked from commit 4e92536)
For anyone else that stumbles upon this issue from a google search before Ansible's official documentation, check out https://docs.ansible.com/ansible/devel/plugins/inventory/constructed.html