[cloud] Group RDS instances by tag keys in ec2 dynamic inventory (#24763)
This commit is contained in:
parent
e0b0e61b32
commit
9364fa202f
1 changed files with 24 additions and 0 deletions
|
@ -1079,6 +1079,24 @@ class Ec2Inventory(object):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.fail_with_error('\n'.join(['Package boto seems a bit older.',
|
self.fail_with_error('\n'.join(['Package boto seems a bit older.',
|
||||||
'Please upgrade boto >= 2.3.0.']))
|
'Please upgrade boto >= 2.3.0.']))
|
||||||
|
# Inventory: Group by tag keys
|
||||||
|
if self.group_by_tag_keys:
|
||||||
|
for k, v in instance.tags.items():
|
||||||
|
if self.expand_csv_tags and v and ',' in v:
|
||||||
|
values = map(lambda x: x.strip(), v.split(','))
|
||||||
|
else:
|
||||||
|
values = [v]
|
||||||
|
|
||||||
|
for v in values:
|
||||||
|
if v:
|
||||||
|
key = self.to_safe("tag_" + k + "=" + v)
|
||||||
|
else:
|
||||||
|
key = self.to_safe("tag_" + k)
|
||||||
|
self.push(self.inventory, key, hostname)
|
||||||
|
if self.nested_groups:
|
||||||
|
self.push_group(self.inventory, 'tags', self.to_safe("tag_" + k))
|
||||||
|
if v:
|
||||||
|
self.push_group(self.inventory, self.to_safe("tag_" + k), key)
|
||||||
|
|
||||||
# Inventory: Group by engine
|
# Inventory: Group by engine
|
||||||
if self.group_by_rds_engine:
|
if self.group_by_rds_engine:
|
||||||
|
@ -1092,6 +1110,12 @@ class Ec2Inventory(object):
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'rds_parameter_groups', self.to_safe("rds_parameter_group_" + instance.parameter_group.name))
|
self.push_group(self.inventory, 'rds_parameter_groups', self.to_safe("rds_parameter_group_" + instance.parameter_group.name))
|
||||||
|
|
||||||
|
# Global Tag: instances without tags
|
||||||
|
if self.group_by_tag_none and len(instance.tags) == 0:
|
||||||
|
self.push(self.inventory, 'tag_none', hostname)
|
||||||
|
if self.nested_groups:
|
||||||
|
self.push_group(self.inventory, 'tags', 'tag_none')
|
||||||
|
|
||||||
# Global Tag: all RDS instances
|
# Global Tag: all RDS instances
|
||||||
self.push(self.inventory, 'rds', hostname)
|
self.push(self.inventory, 'rds', hostname)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue