group_vars by multiple criteria

28 views
Skip to first unread message

Brian N

unread,
Jan 15, 2015, 11:10:59 AM1/15/15
to ansible...@googlegroups.com
Hello. I have an interesting scenario that I have been pondering and would like some input from the community. I would like to apply group_vars to series of servers, that are defined by application roles and also defined by the environments production and pre-producution, So the filter order should be: role --> environment

I am using dynamic inventory, in specific, AWS. 

The following tags are used: 
  • tag_environment_prod
  • tag_environment_preprod
  • tag_role_app1
  • tag_role_app2
EC2 instances would be tagged the following way:

preprod-app1: tag_environment_preprod, tag_role_app1
preprod-app2: tag_environment_preprod, tag_role_app2
prod-app1 :tag_environment_prod, tag_role_app1
Etc....

Regardless of the role assigned to that server, it shares a common configuration file:

#app.conf
APP_KEY={{ app_key }}
APP_THING1={{ app_thing1 }}
APP_THING2={{ app_thing2 }}

My goal is to first filter groups based upon role, then based upon environment. Maybe something like:

/group_vars
    /app1_prod
    /app1_preprod
    /app2_prod
    /app2_preprod

Using a dynamic inventory, how can I accomplish this filter using more than one EC2 tag?

Thanks!
Brian

Reply all
Reply to author
Forward
0 new messages