def _process_section(self, section_value, callback=None, templar=None):
if not templar:
templar = self._templar
processed = ordereddict()
for key, value in section_value.items():
if isinstance(value, string_types):
# strings can be templated
processed[key] = templar.template(value)
if isinstance(processed[key], AnsibleUnsafeText):
processed[key] = str(processed[key])
elif isinstance(value, (list, dict)):
# if it's a dimensional structure, it's cheaper just to serialize
# it, treat it like a template, and then deserialize it again
buffer = BytesIO() # use bytes explicitly, not unicode
yaml.round_trip_dump(value, buffer)
processed[key] = yaml.round_trip_load(
templar.template(buffer.getvalue())
)
else:
# ints, booleans, etc.
processed[key] = value
if callback:
callback(processed)
return processed
评论列表
文章目录