Dynamic inventories, EC2 tags, and commas

Hi all,

I’m managing some Ubuntu EC2 servers with Ansible - they primarily run applications that get deployed with Capistrano, via the cap-ec2 plugin (https://github.com/forward3d/cap-ec2). cap-ec2 looks for a “Roles” tag, featuring a comma-separated list of server roles (app, db, web, worker, etc). In the setup we’re using, one EC2 server can fill multiple roles, so it’s common to see the Roles tag with commas in it. It also uses a “Stages” tag, with values like “production” and “staging”, to indicate environment.

I’d also like to use the ec2.py dynamic inventory script to pull the hosts out of EC2, and run playbooks against our staging app servers, for example. However, it seems like ec2.py doesn’t play well with comma-separated tag values (turning them into underscores). So a server that has Roles: app,web, that will get turned into tag_Roles_app_web, but another server that has Roles: app,worker would be tag_Roles_app_worker.

So my questions for those wiser in dynamic inventory than I: is there a way that I can aggregate any Role that features “app” into an inventory group, using these existing Roles tags? Do I need to set additional tags like “App: true” so that it would turn into tag_App_true and use those instead? Use a bunch of the :children style tags like below?

[app:children]
tag_Roles_app_web
tag_Roles_app_worker

[tag_Roles_app_web]
[tag_Roles_app_worker]

Any suggestions would be appreciated!

Thanks,
Wade

I use this:
In playbook:

`