|
|
|
@ -141,6 +141,7 @@ except ImportError:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Ec2Inventory(object):
|
|
|
|
|
|
|
|
|
|
def _empty_inventory(self):
|
|
|
|
|
return {"_meta" : {"hostvars" : {}}}
|
|
|
|
|
|
|
|
|
@ -321,6 +322,11 @@ class Ec2Inventory(object):
|
|
|
|
|
self.cache_path_index = cache_dir + "/ansible-ec2.index"
|
|
|
|
|
self.cache_max_age = config.getint('ec2', 'cache_max_age')
|
|
|
|
|
|
|
|
|
|
if config.has_option('ec2', 'expand_csv_tags'):
|
|
|
|
|
self.expand_csv_tags = config.getboolean('ec2', 'expand_csv_tags')
|
|
|
|
|
else:
|
|
|
|
|
self.expand_csv_tags = False
|
|
|
|
|
|
|
|
|
|
# Configure nested groups instead of flat namespace.
|
|
|
|
|
if config.has_option('ec2', 'nested_groups'):
|
|
|
|
|
self.nested_groups = config.getboolean('ec2', 'nested_groups')
|
|
|
|
@ -696,6 +702,12 @@ class Ec2Inventory(object):
|
|
|
|
|
# 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:
|
|
|
|
@ -1120,6 +1132,8 @@ class Ec2Inventory(object):
|
|
|
|
|
instance_vars['ec2_placement'] = value.zone
|
|
|
|
|
elif key == 'ec2_tags':
|
|
|
|
|
for k, v in value.items():
|
|
|
|
|
if self.expand_csv_tags and ',' in v:
|
|
|
|
|
v = map(lambda x: x.strip(), v.split(','))
|
|
|
|
|
key = self.to_safe('ec2_tag_' + k)
|
|
|
|
|
instance_vars[key] = v
|
|
|
|
|
elif key == 'ec2_groups':
|
|
|
|
|