ansible/ansible — pull request #7292 by nickpack (2014-05-06 10:48:04+00:00)
Title: Interpret comma seperated values in AWS tags as seperate values

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 [ec2_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: [ec2_tag_role_webserver], [ec2_tag_role_dns], [ec2_tag_role_ssh], [ec2_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