ansible-config, only subvalues should use yaml shorthand (#79073)

* ensure we only use shorthand for assigned values

* fix ansible-config std display

* split baby

* killed offending whitespace

* moved to func instead

* the revenge of whitespace
pull/79082/head
Brian Coca 2 years ago committed by GitHub
parent fcea07bbef
commit 27ab589ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-config limit shorthand format to assigned values

@ -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

Loading…
Cancel
Save