diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2022-10-13 10:42:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 09:42:28 -0500 |
commit | 2ac9e2761b6498c53d68df211b30a4d01599fff4 (patch) | |
tree | 98538e8f7fc14cb4313826859e4cd4ce1df67fc9 | |
parent | 172982e83f60df648371da40174cf2565e772051 (diff) | |
download | ansible-2ac9e2761b6498c53d68df211b30a4d01599fff4.tar.gz |
ansible-config, only subvalues should use yaml shorthand (#79073) (#79078)
(cherry picked from commit 27ab589ee874cac7aad65cfb3630a5b38082e4b8)
-rw-r--r-- | changelogs/fragments/adjust_config_list.yml | 2 | ||||
-rwxr-xr-x | lib/ansible/cli/config.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/changelogs/fragments/adjust_config_list.yml b/changelogs/fragments/adjust_config_list.yml new file mode 100644 index 0000000000..73132b288b --- /dev/null +++ b/changelogs/fragments/adjust_config_list.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-config limit shorthand format to assigned values diff --git a/lib/ansible/cli/config.py b/lib/ansible/cli/config.py index 13c46f1564..3a5c24214b 100755 --- a/lib/ansible/cli/config.py +++ b/lib/ansible/cli/config.py @@ -35,8 +35,12 @@ from ansible.utils.path import unfrackpath display = Display() -def yaml_dump(data, default_flow_style=True): - return yaml.dump(data, Dumper=AnsibleDumper, default_flow_style=default_flow_style, default_style="''") +def yaml_dump(data, default_flow_style=False, default_style=None): + return yaml.dump(data, Dumper=AnsibleDumper, default_flow_style=default_flow_style, default_style=default_style) + + +def yaml_short(data): + return yaml_dump(data, default_flow_style=True, default_style="''") def get_constants(): @@ -305,7 +309,7 @@ class ConfigCLI(CLI): elif subkey == 'vars': if entry.startswith('_ansible_'): continue - data.append(prefix + '%s: %s' % (entry, to_text(yaml_dump(default), errors='surrogate_or_strict'))) + data.append(prefix + '%s: %s' % (entry, to_text(yaml_short(default), errors='surrogate_or_strict'))) data.append('') return data |