Use ensure SafeDumper used yaml configs

With ansible 2.12 they started using CSafeDumper instead of
SafeDumper which ignores indent in yaml files.
To preserver behaviour and config formats we fallback to original
behaviour with indenting.
For that we adjust parenting of AnsibleDumper and adding SafeDumper
when it's not present there.

[1] bfd93c835a/lib/ansible/module_utils/common/yaml.py (L30)

Change-Id: Iadddef84eae31fab9478ad02220ae49d1c91fa4c
This commit is contained in:
Dmitriy Rabotyagov 2022-04-15 12:51:22 +02:00
parent ed68c9d67d
commit 3222aeda8f
1 changed files with 2 additions and 0 deletions

View File

@ -66,6 +66,8 @@ try:
except NameError:
FileNotFoundError = OSError
if yaml.SafeDumper not in AnsibleDumper.__bases__:
AnsibleDumper.__bases__ = (yaml.SafeDumper,) + AnsibleDumper.__bases__
class IDumper(AnsibleDumper):
def increase_indent(self, flow=False, indentless=False):