|
|
|
@ -327,6 +327,12 @@ class Ec2Inventory(object):
|
|
|
|
|
else:
|
|
|
|
|
self.nested_groups = False
|
|
|
|
|
|
|
|
|
|
# Replace dash or not in group names
|
|
|
|
|
if config.has_option('ec2', 'replace_dash_in_groups'):
|
|
|
|
|
self.replace_dash_in_groups = config.getboolean('ec2', 'replace_dash_in_groups')
|
|
|
|
|
else:
|
|
|
|
|
self.replace_dash_in_groups = True
|
|
|
|
|
|
|
|
|
|
# Configure which groups should be created.
|
|
|
|
|
group_by_options = [
|
|
|
|
|
'group_by_instance_id',
|
|
|
|
@ -1285,10 +1291,11 @@ class Ec2Inventory(object):
|
|
|
|
|
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', temp).lower()
|
|
|
|
|
|
|
|
|
|
def to_safe(self, word):
|
|
|
|
|
''' Converts 'bad' characters in a string to underscores so they can be
|
|
|
|
|
used as Ansible groups '''
|
|
|
|
|
|
|
|
|
|
return re.sub("[^A-Za-z0-9\_]", "_", word)
|
|
|
|
|
''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups '''
|
|
|
|
|
regex = "[^A-Za-z0-9\_"
|
|
|
|
|
if self.replace_dash_in_groups:
|
|
|
|
|
regex += "\-"
|
|
|
|
|
return re.sub(regex + "]", "_", word)
|
|
|
|
|
|
|
|
|
|
def json_format_dict(self, data, pretty=False):
|
|
|
|
|
''' Converts a dict to a JSON object and dumps it as a formatted
|
|
|
|
|