summaryrefslogtreecommitdiff
path: root/bin/ansible-config
diff options
context:
space:
mode:
authorcos <cos>2024-04-20 09:15:12 +0200
committercos <cos>2024-04-20 09:44:47 +0200
commitbbed591285e1882d05198e518f75873af58939f5 (patch)
treec25b33652187f7070d0c2467663c11d6cd4e2326 /bin/ansible-config
parentc4f015da4ac75017b97c24ef6601bdd98872e60f (diff)
downloaddebian-ansible-core-bbed591285e1882d05198e518f75873af58939f5.zip
Attempt to recreate upstream branch state from tar filesupstream/failed-recreation-attempt
Unfortunately this was a too naive approach, and the result fails to build. Work around that version control is behind the actual package version in trixie. As is obvious from the lacking commits in the salsa repository and also visible on https://tracker.debian.org/pkg/ansible-core with the report from vcswatch stating: VCS repository is not up to date. This commit contains all changes from ansible-core_2.14.13.orig.tar.gz to ansible-core_2.16.5.orig.tar.gz, which should hopefully be a squashed representation on the same set of changes on the uploader's unpushed git tree.
Diffstat (limited to 'bin/ansible-config')
-rwxr-xr-xbin/ansible-config42
1 files changed, 25 insertions, 17 deletions
diff --git a/bin/ansible-config b/bin/ansible-config
index c8d99ea0..f394ef7c 100755
--- a/bin/ansible-config
+++ b/bin/ansible-config
@@ -23,7 +23,7 @@ from ansible import constants as C
from ansible.cli.arguments import option_helpers as opt_help
from ansible.config.manager import ConfigManager, Setting
from ansible.errors import AnsibleError, AnsibleOptionsError
-from ansible.module_utils._text import to_native, to_text, to_bytes
+from ansible.module_utils.common.text.converters import to_native, to_text, to_bytes
from ansible.module_utils.common.json import json_dump
from ansible.module_utils.six import string_types
from ansible.parsing.quoting import is_quoted
@@ -67,7 +67,7 @@ class ConfigCLI(CLI):
desc="View ansible configuration.",
)
- common = opt_help.argparse.ArgumentParser(add_help=False)
+ common = opt_help.ArgumentParser(add_help=False)
opt_help.add_verbosity_options(common)
common.add_argument('-c', '--config', dest='config_file',
help="path to configuration file, defaults to first file found in precedence.")
@@ -187,7 +187,7 @@ class ConfigCLI(CLI):
# pylint: disable=unreachable
try:
- editor = shlex.split(os.environ.get('EDITOR', 'vi'))
+ editor = shlex.split(C.config.get_config_value('EDITOR'))
editor.append(self.config_file)
subprocess.call(editor)
except Exception as e:
@@ -314,7 +314,7 @@ class ConfigCLI(CLI):
return data
- def _get_settings_ini(self, settings):
+ def _get_settings_ini(self, settings, seen):
sections = {}
for o in sorted(settings.keys()):
@@ -327,7 +327,7 @@ class ConfigCLI(CLI):
if not opt.get('description'):
# its a plugin
- new_sections = self._get_settings_ini(opt)
+ new_sections = self._get_settings_ini(opt, seen)
for s in new_sections:
if s in sections:
sections[s].extend(new_sections[s])
@@ -343,37 +343,45 @@ class ConfigCLI(CLI):
if 'ini' in opt and opt['ini']:
entry = opt['ini'][-1]
+ if entry['section'] not in seen:
+ seen[entry['section']] = []
if entry['section'] not in sections:
sections[entry['section']] = []
- default = opt.get('default', '')
- if opt.get('type', '') == 'list' and not isinstance(default, string_types):
- # python lists are not valid ini ones
- default = ', '.join(default)
- elif default is None:
- default = ''
+ # avoid dupes
+ if entry['key'] not in seen[entry['section']]:
+ seen[entry['section']].append(entry['key'])
+
+ default = opt.get('default', '')
+ if opt.get('type', '') == 'list' and not isinstance(default, string_types):
+ # python lists are not valid ini ones
+ default = ', '.join(default)
+ elif default is None:
+ default = ''
+
+ if context.CLIARGS['commented']:
+ entry['key'] = ';%s' % entry['key']
- if context.CLIARGS['commented']:
- entry['key'] = ';%s' % entry['key']
+ key = desc + '\n%s=%s' % (entry['key'], default)
- key = desc + '\n%s=%s' % (entry['key'], default)
- sections[entry['section']].append(key)
+ sections[entry['section']].append(key)
return sections
def execute_init(self):
"""Create initial configuration"""
+ seen = {}
data = []
config_entries = self._list_entries_from_args()
plugin_types = config_entries.pop('PLUGINS', None)
if context.CLIARGS['format'] == 'ini':
- sections = self._get_settings_ini(config_entries)
+ sections = self._get_settings_ini(config_entries, seen)
if plugin_types:
for ptype in plugin_types:
- plugin_sections = self._get_settings_ini(plugin_types[ptype])
+ plugin_sections = self._get_settings_ini(plugin_types[ptype], seen)
for s in plugin_sections:
if s in sections:
sections[s].extend(plugin_sections[s])