From 24216eba2981302fface62e89eaf2d22792290ea Mon Sep 17 00:00:00 2001 From: rexredinger Date: Tue, 17 Apr 2018 16:03:13 -0400 Subject: [PATCH] Fix for RLM 1374: mapped sequence indentation --- playbooks/scripts/required_user_config_keys.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/playbooks/scripts/required_user_config_keys.py b/playbooks/scripts/required_user_config_keys.py index 8da4cfba..5661ea14 100644 --- a/playbooks/scripts/required_user_config_keys.py +++ b/playbooks/scripts/required_user_config_keys.py @@ -32,6 +32,17 @@ """ +class IndentFix(yaml.Dumper): + """This address RLM 1374, proper indentation for mapped sequence blocks + + Pass this as the Dumper class when making calls to yaml.dump() to ensure + indentation remains consistent. + """ + + def increase_indent(self, flow=False, indentless=False): + return super(IndentFix, self).increase_indent(flow, False) + + def key_check_add(key, user_config_file, changed=False): """Add key if missing in the openstack_user_config.yml @@ -71,7 +82,8 @@ def key_check_add(key, user_config_file, changed=False): yaml.dump( user_config, default_flow_style=False, - width=1000 + width=1000, + Dumper=IndentFix ) )