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

Updated version of my original PR #7292 to incorporate nested group changes #8676

wants to merge 1 commit into
base: devel


None yet
5 participants

nickpack commented Aug 19, 2014

My previous PR for the expanding of CSV values in ec2 tags did not merge cleanly with the current devel HEAD, so have updated the patches to resolve this.


This comment has been minimized.

nickpack commented Aug 19, 2014

Context from previous PR:

In my current environment, I rely heavily on AWS tags to describe the purpose of boxes, and roles are applied specifically to them via tag values. In instances where a machine is filling more than one role, I needed the flexibility to target specific instances by tag grouping. This commit aims to prevent a significant amount of tags being required by expanding a CSV value for a tag into a list of values.

The hostvars ec2_tag_foo value becomes a list of tag values from splitting the field by comma, and an additional group tag_foo_value is added to the inventory for each of the CSV values.

An example of one of the machine tags is:
Name: role, Value: webserver,dns,ssh,logger

Without this commit, the value is interpreted as: ec2_tag_role = 'webserver_dns_ssh_logger' and in the inventory there is a key [tag_role_webserver_dns_ssh_logger]

With this commit, the value is interpreted as: ec2_tag_role = [
'webserver', 'dns', 'ssh', 'logger'

and in the inventory there are groups: [tag_role_webserver], [tag_role_dns], [tag_role_ssh], [tag_role_logger]

Therefore buying the flexibility of being able to target instances by specific role, and avoiding having to create a tonne of additional tags/hostgroup handlers


This comment has been minimized.


mpdehaan commented Aug 19, 2014

Linking with ticket #7292


This comment has been minimized.


amenonsen commented Jul 26, 2015

@nickpack any chance you could rebase again to apply to current devel? I'd find this functionality useful myself.

@bcoca bcoca added the needs_rebase label Jul 26, 2015

amenonsen added a commit to amenonsen/ansible that referenced this pull request Nov 12, 2015

Add an expand_csv_tags setting to ec2.ini
If enabled, this will convert tags of the form "a,b,c" to a list and use
the results to create additional inventory groups.

This is based on PR ansible#8676 by nickpeck (but not a straight rebase—both
the code and the nomenclature have been changed here).

Closes ansible#8676

@bcoca bcoca closed this in #12640 Nov 12, 2015

@ansibot ansibot added feature and removed feature_pull_request labels Mar 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment