-
Notifications
You must be signed in to change notification settings - Fork 23.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dynamic group intersections to inventory file #10131
Comments
I would absolutely love to have this - I have a lot of ugly-as-sin J2 loops performing this functionality right now ( |
Method 2: Define one static group composed of intersection of two dynamic groups[tag_aws_autoscaling_groupName_Frontend:&us-west-2] 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! |
+1 for this feature. |
My recent questions about this are related to this. My need is to Suggestions welcome. On Friday, July 17, 2015, Andrew Sannier notifications@github.com wrote:
|
I have 400+ servers on EC2 and I make large use of Tags to classify VMs, having support for intersection would improve Ansible flexibility in a such large environment. +1 |
Interesting idea. Definitely needs a bigger discussion on 'dynamic groups'. |
My problem is that many servers are managed by auto-scaling groups and this makes the manually defined groups obsolete in less than one day. |
On 26 August 2015 at 20:27, MadGhigno notifications@github.com 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 |
you can use the current group_by task to do this, for example, simple intersection of group1 and group2:
|
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 notifications@github.com
|
On 30 September 2015 at 07:38, Andrew Sannier notifications@github.com
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. K. |
+1 I've also run into this issue where I'd like to intersect two dynamic groups. |
+1 |
+1! |
+1 |
Using these tricks feels really awkward from a user experience perspective. Does anyone have a more complete example of @sanear's trick? |
Switch to ProposalHi! 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. https://github.com/ansible/proposals/blob/master/proposals_process_proposal.md If you have any further questions, please let us know by stopping by our devel mailing list, or our devel IRC channel:
Thank you! |
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. ansible-meta-dynamic-invetory repository @pporada-gl @cobyrne09 @toidi @carmi @tartansandal @sanear @srvg @MadGhigno @archit @ckonkel @rhartkopf |
@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 <didi@redhat.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 <didi@redhat.com> (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 |
Issue Type:
Feature Idea
Ansible Version:
ansible 1.9
Environment:
N/A
Summary:
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
hosts/static:
Expected Results:
🔵 Control:
🔵 Method 1:
🔵 Method 2:
Actual Results:
🔵 Control:
🔴 Method 1:
🔴 Method 2:
The text was updated successfully, but these errors were encountered: