Skip to content

Add Dynamic group intersections to inventory file #10131

Description

@rhartkopf
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:

# One static host
[all]
host1

[east]
host2

[west]
host3

# Method 1: Define two static groups composed of one dynamic group
[tag_aws_autoscaling_groupName_Frontend]
[us-east-1]

# Method 2: Define one static group composed of intersection of two dynamic groups
[tag_aws_autoscaling_groupName_Frontend:&us-west-2]

# Control: Set one dynamic group as child
[all:children]
tag_aws_autoscaling_groupName_Frontend

# Set intersection of dynamic groups as children
[east:children]
tag_aws_autoscaling_groupName_Frontend:&us-east-1

[west:children]
tag_aws_autoscaling_groupName_Frontend:&us-west-2

Expected Results:

🔵 Control:

$ ansible -i hosts all --list-hosts
host1
54.xxx.xxx.xxx (hosts from all regions)

🔵 Method 1:

$ ansible -i hosts east --list-hosts
host2
54.xxx.xxx.xxx (hosts from us-east-1)

🔵 Method 2:

$ ansible -i hosts west --list-hosts
host3
54.xxx.xxx.xxx (hosts from us-west-2)
Actual Results:

🔵 Control:

$ ansible -i hosts all --list-hosts
host1
54.xxx.xxx.xxx (hosts from all regions)

🔴 Method 1:

$ ansible -i hosts east --list-hosts
ERROR: child group is not defined: (tag_aws_autoscaling_groupName_Frontend:&us-east-1)

🔴 Method 2:

$ ansible -i hosts west --list-hosts
host3

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature request.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions