mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds a flag (is_redis) to prevent duplicity of information about Redis single node clusters
This commit is contained in:
parent
2a242a0e1b
commit
e64daba8e7
1 changed files with 9 additions and 5 deletions
|
@ -702,9 +702,13 @@ class Ec2Inventory(object):
|
||||||
if 'ConfigurationEndpoint' in cluster and cluster['ConfigurationEndpoint']:
|
if 'ConfigurationEndpoint' in cluster and cluster['ConfigurationEndpoint']:
|
||||||
# Memcached cluster
|
# Memcached cluster
|
||||||
dest = cluster['ConfigurationEndpoint']['Address']
|
dest = cluster['ConfigurationEndpoint']['Address']
|
||||||
|
is_redis = False
|
||||||
else:
|
else:
|
||||||
# Redis sigle node cluster
|
# 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']
|
dest = cluster['CacheNodes'][0]['Endpoint']['Address']
|
||||||
|
is_redis = True
|
||||||
|
|
||||||
if not dest:
|
if not dest:
|
||||||
# Skip clusters we cannot address (e.g. private VPC subnet)
|
# 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'])
|
self.push_group(self.inventory, 'instances', cluster['CacheClusterId'])
|
||||||
|
|
||||||
# Inventory: Group by region
|
# Inventory: Group by region
|
||||||
if self.group_by_region:
|
if self.group_by_region and not is_redis:
|
||||||
self.push(self.inventory, region, dest)
|
self.push(self.inventory, region, dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'regions', region)
|
self.push_group(self.inventory, 'regions', region)
|
||||||
|
|
||||||
# Inventory: Group by availability zone
|
# 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)
|
self.push(self.inventory, cluster['PreferredAvailabilityZone'], dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
if self.group_by_region:
|
if self.group_by_region:
|
||||||
|
@ -734,7 +738,7 @@ class Ec2Inventory(object):
|
||||||
self.push_group(self.inventory, 'zones', cluster['PreferredAvailabilityZone'])
|
self.push_group(self.inventory, 'zones', cluster['PreferredAvailabilityZone'])
|
||||||
|
|
||||||
# Inventory: Group by node type
|
# 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'])
|
type_name = self.to_safe('type_' + cluster['CacheNodeType'])
|
||||||
self.push(self.inventory, type_name, dest)
|
self.push(self.inventory, type_name, dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
|
@ -748,7 +752,7 @@ class Ec2Inventory(object):
|
||||||
# self.push_group(self.inventory, 'vpcs', vpc_id_name)
|
# self.push_group(self.inventory, 'vpcs', vpc_id_name)
|
||||||
|
|
||||||
# Inventory: Group by security group
|
# 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:
|
if 'SecurityGroups' in cluster:
|
||||||
for security_group in cluster['SecurityGroups']:
|
for security_group in cluster['SecurityGroups']:
|
||||||
key = self.to_safe("security_group_" + security_group['SecurityGroupId'])
|
key = self.to_safe("security_group_" + security_group['SecurityGroupId'])
|
||||||
|
@ -757,7 +761,7 @@ class Ec2Inventory(object):
|
||||||
self.push_group(self.inventory, 'security_groups', key)
|
self.push_group(self.inventory, 'security_groups', key)
|
||||||
|
|
||||||
# Inventory: Group by engine
|
# 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)
|
self.push(self.inventory, self.to_safe("elasticache_" + cluster['Engine']), dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'elasticache_engines', self.to_safe(cluster['Engine']))
|
self.push_group(self.inventory, 'elasticache_engines', self.to_safe(cluster['Engine']))
|
||||||
|
|
Loading…
Reference in a new issue