diff --git a/changelogs/fragments/72697-improve-config-deprecations.yml b/changelogs/fragments/72697-improve-config-deprecations.yml new file mode 100644 index 00000000000..d64b33d383d --- /dev/null +++ b/changelogs/fragments/72697-improve-config-deprecations.yml @@ -0,0 +1,2 @@ +bugfixes: +- "Improve Ansible config deprecations to show the source of the deprecation (ansible-core). Also remove space before a comma in config deprecations (https://github.com/ansible/ansible/pull/72697)." diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index 874dc92a2ad..112d892da4e 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -98,7 +98,7 @@ class CLI(with_metaclass(ABCMeta, object)): ver = deprecated[1].get('version') date = deprecated[1].get('date') collection_name = deprecated[1].get('collection_name') - display.deprecated("%s option, %s %s" % (name, why, alt), + display.deprecated("%s option, %s%s" % (name, why, alt), version=ver, date=date, collection_name=collection_name) @staticmethod diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index cca8d2b455d..501492a6fb2 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -4,7 +4,7 @@ ALLOW_WORLD_READABLE_TMPFILES: name: Allow world-readable temporary files deprecated: - why: moved to a per plugin approach that is more flexible. + why: moved to a per plugin approach that is more flexible version: "2.14" alternatives: mostly the same config will work, but now controlled from the plugin itself and not using the general constant. default: False @@ -43,7 +43,7 @@ ANSIBLE_COW_ACCEPTLIST: env: - name: ANSIBLE_COW_WHITELIST deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'ANSIBLE_COW_ACCEPTLIST' - name: ANSIBLE_COW_ACCEPTLIST @@ -52,7 +52,7 @@ ANSIBLE_COW_ACCEPTLIST: - key: cow_whitelist section: defaults deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'cowsay_enabled_stencils' - key: cowsay_enabled_stencils @@ -438,7 +438,7 @@ COMMAND_WARNINGS: type: boolean version_added: "1.8" deprecated: - why: The command warnings feature is being removed. + why: the command warnings feature is being removed version: "2.14" LOCALHOST_WARNING: name: Warning when using implicit inventory with only localhost @@ -574,7 +574,7 @@ CALLABLE_ACCEPT_LIST: env: - name: ANSIBLE_CALLABLE_WHITELIST deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'ANSIBLE_CALLABLE_ENABLED' - name: ANSIBLE_CALLABLE_ENABLED @@ -583,7 +583,7 @@ CALLABLE_ACCEPT_LIST: - key: callable_whitelist section: defaults deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'callable_enabled' - key: callable_enabled @@ -617,7 +617,7 @@ CALLBACKS_ENABLED: env: - name: ANSIBLE_CALLBACK_WHITELIST deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'ANSIBLE_CALLBACKS_ENABLED' - name: ANSIBLE_CALLBACKS_ENABLED @@ -626,7 +626,7 @@ CALLBACKS_ENABLED: - key: callback_whitelist section: defaults deprecated: - why: Normalizing names to new standard. + why: normalizing names to new standard version: "2.15" alternatives: 'callback_enabled' - key: callbacks_enabled @@ -782,7 +782,7 @@ DEFAULT_HASH_BEHAVIOUR: ini: - {key: hash_behaviour, section: defaults} deprecated: - why: This feature is fragile and not portable, leading to continual confusion and misuse + why: this feature is fragile and not portable, leading to continual confusion and misuse version: "2.13" alternatives: the ``combine`` filter explicitly DEFAULT_HOST_LIST: @@ -1839,7 +1839,7 @@ PLUGIN_FILTERS_CFG: - key: plugin_filters_cfg section: default deprecated: - why: Specifying "plugin_filters_cfg" under the "default" section is deprecated + why: specifying "plugin_filters_cfg" under the "default" section is deprecated version: "2.12" alternatives: the "defaults" section instead - key: plugin_filters_cfg diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index dfc85387ddb..7ef437a6139 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -266,6 +266,20 @@ def find_ini_config_file(warnings=None): return path +def _add_base_defs_deprecations(base_defs): + '''Add deprecation source 'ansible.builtin' to deprecations in base.yml''' + def process(entry): + if 'deprecated' in entry: + entry['deprecated']['collection_name'] = 'ansible.builtin' + + for dummy, data in base_defs.items(): + process(data) + for section in ('ini', 'env', 'vars'): + if section in data: + for entry in data[section]: + process(entry) + + class ConfigManager(object): DEPRECATED = [] @@ -281,6 +295,7 @@ class ConfigManager(object): self.data = ConfigData() self._base_defs = self._read_config_yaml_file(defs_file or ('%s/base.yml' % os.path.dirname(__file__))) + _add_base_defs_deprecations(self._base_defs) if self._config_file is None: # set config using ini