AC-1134 Updated rax/ec2 inventory scripts from ansible. Added ability to filter groups/hosts by regular expression and exclude empty groups, so that Tower can exclude RAX/EC2 instance ID groups and EC2 RDS hosts/groups.

This commit is contained in:
Chris Church
2014-04-08 23:50:57 -04:00
parent 59dc2a2cb8
commit 1283a78e09
6 changed files with 268 additions and 110 deletions

View File

@@ -254,8 +254,7 @@ class Ec2Inventory(object):
for region in self.regions:
self.get_instances_by_region(region)
# Don't return RDS instances for Ansible Tower!
#self.get_rds_instances_by_region(region)
self.get_rds_instances_by_region(region)
self.write_to_cache(self.inventory, self.cache_path_cache)
self.write_to_cache(self.index, self.cache_path_index)
@@ -344,9 +343,8 @@ class Ec2Inventory(object):
# Add to index
self.index[dest] = [region, instance.id]
# Do not output group based on instance ID for Ansible Tower!
# Inventory: Group by instance ID (always a group of 1)
#self.inventory[instance.id] = [dest]
self.inventory[instance.id] = [dest]
# Inventory: Group by region
self.push(self.inventory, region, dest)