1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1954 from lorin/ec2-facts-fix

If ec2 fact has ':' or '-', change to '_'
This commit is contained in:
Michael DeHaan 2013-02-01 18:10:47 -08:00
commit 1d638d62ee

View file

@ -96,12 +96,21 @@ class Ec2Metadata(object):
else:
self._data['%s' % (new_uri)] = content
def fix_invalid_varnames(self, data):
"""Change ':'' and '-' to '_' to ensure valid template variable names"""
for (key, value) in data.items():
if ':' in key or '-' in key:
newkey = key.replace(':','_').replace('-','_')
data[newkey] = value
def run(self):
self.fetch(self.uri_meta) # populate _data
data = self._mangle_fields(self._data,
self.uri_meta)
data[self._prefix % 'user-data'] = self._fetch(self.uri_user)
data[self._prefix % 'public-key'] = self._fetch(self.uri_ssh)
self.fix_invalid_varnames(data)
return data