diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2022-01-20 10:13:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 09:13:52 -0600 |
commit | dd2e695c93e06451cfed46f6eb30eb2d8231d29b (patch) | |
tree | 2d947c2fb53a4219adc4a547b40585091cd5841f | |
parent | 83d7716e02f78685509337efc8dbbd7212020b22 (diff) | |
download | ansible-dd2e695c93e06451cfed46f6eb30eb2d8231d29b.tar.gz |
ansible-config avoid _terms and _input in --only-changed (#76597) (#76763)
dont display _terms or _intput on only changed
those always change and it expected for the plugins that support them
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 2246ed96786c600e5c5d9c120c77de1968282d85)
-rw-r--r-- | changelogs/fragments/config_fix_terms.yml | 2 | ||||
-rw-r--r-- | lib/ansible/cli/config.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/changelogs/fragments/config_fix_terms.yml b/changelogs/fragments/config_fix_terms.yml new file mode 100644 index 0000000000..9825a49c96 --- /dev/null +++ b/changelogs/fragments/config_fix_terms.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-config avoid showing _terms and _input when --only-changed. diff --git a/lib/ansible/cli/config.py b/lib/ansible/cli/config.py index 328b3c1110..0fff37441c 100644 --- a/lib/ansible/cli/config.py +++ b/lib/ansible/cli/config.py @@ -365,18 +365,23 @@ class ConfigCLI(CLI): text = [] for setting in sorted(config): + changed = False if isinstance(config[setting], Setting): + # proceed normally if config[setting].origin == 'default': color = 'green' elif config[setting].origin == 'REQUIRED': + # should include '_terms', '_input', etc color = 'red' else: color = 'yellow' + changed = True msg = "%s(%s) = %s" % (setting, config[setting].origin, config[setting].value) else: color = 'green' msg = "%s(%s) = %s" % (setting, 'default', config[setting].get('default')) - if not context.CLIARGS['only_changed'] or color == 'yellow': + + if not context.CLIARGS['only_changed'] or changed: text.append(stringc(msg, color)) return text @@ -440,6 +445,11 @@ class ConfigCLI(CLI): o = 'REQUIRED' else: raise e + + if v is None and o is None: + # not all cases will be error + o = 'REQUIRED' + config_entries[finalname][setting] = Setting(setting, v, o, None) # pretty please! |