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

Don't use iteritems() in templar to avoid (hostvars) dict size change errors

This commit is contained in:
James Cammarata 2015-09-01 14:11:23 -04:00
parent 974b69d236
commit 3e1a774ba5

View file

@ -251,8 +251,10 @@ class Templar:
return [self.template(v, convert_bare=convert_bare, preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides) for v in variable] return [self.template(v, convert_bare=convert_bare, preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides) for v in variable]
elif isinstance(variable, dict): elif isinstance(variable, dict):
d = {} d = {}
for (k, v) in variable.iteritems(): # we don't use iteritems() here to avoid problems if the underlying dict
d[k] = self.template(v, convert_bare=convert_bare, preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides) # changes sizes due to the templating, which can happen with hostvars
for k in variable.keys():
d[k] = self.template(variable[k], convert_bare=convert_bare, preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides)
return d return d
else: else:
return variable return variable