From e64daba8e72deee8b97d06ed2a3076ed32a607ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Schr=C3=B6der?= Date: Sun, 14 Jun 2015 23:10:33 +0200 Subject: [PATCH] Adds a flag (is_redis) to prevent duplicity of information about Redis single node clusters --- plugins/inventory/ec2.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index cec994798cf..3dddbc65b2c 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -702,9 +702,13 @@ class Ec2Inventory(object): if 'ConfigurationEndpoint' in cluster and cluster['ConfigurationEndpoint']: # Memcached cluster dest = cluster['ConfigurationEndpoint']['Address'] + is_redis = False else: # Redis sigle node cluster + # Because all Redis clusters are single nodes, we'll merge the + # info from the cluster with info about the node dest = cluster['CacheNodes'][0]['Endpoint']['Address'] + is_redis = True if not dest: # Skip clusters we cannot address (e.g. private VPC subnet) @@ -720,13 +724,13 @@ class Ec2Inventory(object): self.push_group(self.inventory, 'instances', cluster['CacheClusterId']) # Inventory: Group by region - if self.group_by_region: + if self.group_by_region and not is_redis: self.push(self.inventory, region, dest) if self.nested_groups: self.push_group(self.inventory, 'regions', region) # Inventory: Group by availability zone - if self.group_by_availability_zone: + if self.group_by_availability_zone and not is_redis: self.push(self.inventory, cluster['PreferredAvailabilityZone'], dest) if self.nested_groups: if self.group_by_region: @@ -734,7 +738,7 @@ class Ec2Inventory(object): self.push_group(self.inventory, 'zones', cluster['PreferredAvailabilityZone']) # Inventory: Group by node type - if self.group_by_instance_type: + if self.group_by_instance_type and not is_redis: type_name = self.to_safe('type_' + cluster['CacheNodeType']) self.push(self.inventory, type_name, dest) if self.nested_groups: @@ -748,7 +752,7 @@ class Ec2Inventory(object): # self.push_group(self.inventory, 'vpcs', vpc_id_name) # Inventory: Group by security group - if self.group_by_security_group: + if self.group_by_security_group and not is_redis: if 'SecurityGroups' in cluster: for security_group in cluster['SecurityGroups']: key = self.to_safe("security_group_" + security_group['SecurityGroupId']) @@ -757,7 +761,7 @@ class Ec2Inventory(object): self.push_group(self.inventory, 'security_groups', key) # Inventory: Group by engine - if self.group_by_elasticache_engine: + if self.group_by_elasticache_engine and not is_redis: self.push(self.inventory, self.to_safe("elasticache_" + cluster['Engine']), dest) if self.nested_groups: self.push_group(self.inventory, 'elasticache_engines', self.to_safe(cluster['Engine']))