ansible-config init fixes (#78453)

* ansible-config init fixes

  now handles --disabled correctly for 'vars' format
  also does not display internal config entries anymore

  fixes #78438

note plugins have _prefixed settings that are public, this should change
pull/78528/head
Brian Coca 2 years ago committed by GitHub
parent 2729088f2a
commit 740864869e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- "`ansible-config init -f vars` will now use shorthand format"
- ansible-configi init should now skip internal reserved config entries

@ -36,7 +36,7 @@ display = Display()
def yaml_dump(data, default_flow_style=True):
return yaml.dump(data, Dumper=AnsibleDumper, default_flow_style=default_flow_style)
return yaml.dump(data, Dumper=AnsibleDumper, default_flow_style=default_flow_style, default_style="''")
def get_constants():
@ -299,9 +299,13 @@ class ConfigCLI(CLI):
# TODO: might need quoting and value coercion depending on type
if subkey == 'env':
if entry.startswith('_ANSIBLE_'):
continue
data.append('%s%s=%s' % (prefix, entry, default))
elif subkey == 'vars':
data.append(prefix + to_text(yaml_dump({entry: default}, default_flow_style=False), errors='surrogate_or_strict'))
if entry.startswith('_ansible_'):
continue
data.append(prefix + '%s: %s' % (entry, to_text(yaml_dump(default), errors='surrogate_or_strict')))
data.append('')
return data

Loading…
Cancel
Save