EC2 module not filtering tags from different vpc

83 views
Skip to first unread message

Gary Malouf

unread,
Feb 9, 2015, 11:49:30 PM2/9/15
to ansible...@googlegroups.com
We are experimenting with a staging and production environment each in their own vpc.  It has been a struggle to use the EC2 module with this setup because despite applying instance filters to ec2. ini, the 'count' tags used in the ec2 module for provisioning count instances across vpcs if they have the same tag.  Ths instance filters are using vpc ids, I can see this works when running a simple list of instances but the exact count setting in the EC2 module counts instances with tags across vpcs anyways.

Gary Malouf

unread,
Feb 10, 2015, 7:38:48 AM2/10/15
to ansible...@googlegroups.com
I'll try to be more clear on the issue.  We have 8 tags/groups per environment (staging/production) in different vpcs that need services provisioned and updated in EC2:

webservers
databases
dashboards
etc...

Since you can not use a variable from /etc/ansible in the 'hosts:' setting in a playbook, we can either 

- use different group names for each environment (and hence need different plays per)
- ideally, use the same tag_Name setting across environments and rely on the ec2.py/ini combo to filter for the right instances based on vpc subnet id

The second case is preferable, but despite filtering by vpc_id in ec2.py, the 'exact_count' setting in the ec2 module for provisioning looks at the number of instances tagged across vpcs.  

Does anyone know of a way to make it only consider the instances that pass the instance filters from the dynamic inventory script?

James Cammarata

unread,
Feb 10, 2015, 9:04:13 AM2/10/15
to ansible...@googlegroups.com
Hi Gary, the tag names from the dynamic inventory are brought in as group names for the instances, so I would use group_vars/TAG_NAME to bring in those specific variables. Alternatively, you could use the include_vars module to include YAML files based on variables available (like the tag name).

Hope that helps!

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9d6fbc44-1942-4a08-8773-7d16a7feda5d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages