From 3222aeda8f6a2d380802153a15a5fd961d356024 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 15 Apr 2022 12:51:22 +0200 Subject: [PATCH] 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] https://github.com/ansible/ansible/blob/bfd93c835afdca638fe0757d64a9a2a4e7e72cdc/lib/ansible/module_utils/common/yaml.py#L30 Change-Id: Iadddef84eae31fab9478ad02220ae49d1c91fa4c --- plugins/action/config_template.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/action/config_template.py b/plugins/action/config_template.py index d270da2..472d483 100644 --- a/plugins/action/config_template.py +++ b/plugins/action/config_template.py @@ -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):