Skip to content
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

Allow case of a list of constructed parent groups #53812

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
2 participants
@AlanCoding
Copy link
Member

AlanCoding commented Mar 14, 2019

SUMMARY

This allows nesting of groups in the way that ec2.py does for tags. It builds directly on top of what was done in #53649. There, templating was allowed, here, a conditional decision is made depending on the type produced by the templating.

This allows dictating parent groups in a way like:

the key entry templates into ["a", "b", "c"]. This means that the current host will be added to the groups a, b, and c.

the parent_groups entry templates into ["x", "y", "z"]. This change makes it so that parentage is established in the manner:

  • x->a
  • y->b
  • z->c

If a static parent group is given, then a, b, and c will all become direct children of one group with that static name. This only makes a difference when the user gives a parent group template that produces a list.

The current behavior in devel for this case is that it errors as some regex method gets and unexpected type.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

constructed inventory plugin

ADDITIONAL INFORMATION

If you have this patch, the case for ec2.py tags is reproduced with syntax like the following:

  - prefix: tag
    key: tags.keys()
    parent_group: tags
  - key: tags
    parent_group: '{{ tags.keys() | list | map("regex_replace", "^(.*)$", "tag_\1") | list }}'
    prefix: tag

(this ignores the unsafe character matching for simplicity)

This creates groups like

  • tags -> tag_Name -> tag_Name_github_stuff -> my_host

There is only 1 nuanced difference, where my_host is a member of tag_Name directly in this version. In ec2.py it was not a direct member, but of course, was an indirect member. Since the goal is to be a superset, I thought this is acceptable.

Ping @s-hertel @bcoca, this was so complicated to explain it that I thought I'd just do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.