plugins: remove deprecated features (#82976)

* Remove deprecated REQUIRE_WHITELIST
* Remove deprecated module_blacklist

Fixes: #82947

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2024-04-04 12:29:50 -07:00 committed by GitHub
parent 5f36fc9a46
commit 52529f0b8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 28 deletions

View File

@ -0,0 +1,3 @@
---
removed_features:
- loader - remove deprecated non-inclusive words (https://github.com/ansible/ansible/issues/82947).

View File

@ -1098,10 +1098,6 @@ class PluginLoader:
needs_enabled = False
if hasattr(obj, 'REQUIRES_ENABLED'):
needs_enabled = obj.REQUIRES_ENABLED
elif hasattr(obj, 'REQUIRES_WHITELIST'):
needs_enabled = obj.REQUIRES_WHITELIST
display.deprecated("The VarsModule class variable 'REQUIRES_WHITELIST' is deprecated. "
"Use 'REQUIRES_ENABLED' instead.", version=2.18)
if not needs_enabled:
# Use get_with_context to cache the plugin the first time we see it.
self.get_with_context(fqcn)[0]
@ -1412,13 +1408,6 @@ def _load_plugin_filter():
# Modules and action plugins share the same reject list since the difference between the
# two isn't visible to the users
if version == u'1.0':
if 'module_blacklist' in filter_data:
display.deprecated("'module_blacklist' is being removed in favor of 'module_rejectlist'", version='2.18')
if 'module_rejectlist' not in filter_data:
filter_data['module_rejectlist'] = filter_data['module_blacklist']
del filter_data['module_blacklist']
try:
filters['ansible.modules'] = frozenset(filter_data['module_rejectlist'])
except TypeError:

View File

@ -90,7 +90,7 @@ def get_vars_from_path(loader, path, entities, stage):
collection = '.' in plugin.ansible_name and not plugin.ansible_name.startswith('ansible.builtin.')
# Warn if a collection plugin has REQUIRES_ENABLED because it has no effect.
if collection and (hasattr(plugin, 'REQUIRES_ENABLED') or hasattr(plugin, 'REQUIRES_WHITELIST')):
if collection and hasattr(plugin, 'REQUIRES_ENABLED'):
display.warning(
"Vars plugins in collections must be enabled to be loaded, REQUIRES_ENABLED is not supported. "
"This should be removed from the plugin %s." % plugin.ansible_name

View File

@ -1,10 +0,0 @@
from __future__ import annotations
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
REQUIRES_WHITELIST = True
def get_vars(self, loader, path, entities):
return {}

View File

@ -14,13 +14,10 @@ export ANSIBLE_VARS_ENABLED=require_enabled
# Test deprecated features
export ANSIBLE_VARS_PLUGINS=./deprecation_warning
WARNING_1="The VarsModule class variable 'REQUIRES_WHITELIST' is deprecated. Use 'REQUIRES_ENABLED' instead."
WARNING_2="The vars plugin v2_vars_plugin .* is relying on the deprecated entrypoints 'get_host_vars' and 'get_group_vars'"
WARNING="The vars plugin v2_vars_plugin .* is relying on the deprecated entrypoints 'get_host_vars' and 'get_group_vars'"
ANSIBLE_DEPRECATION_WARNINGS=True ANSIBLE_NOCOLOR=True ANSIBLE_FORCE_COLOR=False \
ansible-inventory -i localhost, --list all "$@" 2> err.txt
for WARNING in "$WARNING_1" "$WARNING_2"; do
ansible localhost -m debug -a "msg={{ lookup('file', 'err.txt') | regex_replace('\n', '') }}" | grep "$WARNING"
done
ansible localhost -m debug -a "msg={{ lookup('file', 'err.txt') | regex_replace('\n', '') }}" | grep "$WARNING"
# Test how many times vars plugins are loaded for a simple play containing a task
# host_group_vars is stateless, so we can load it once and reuse it, every other vars plugin should be instantiated before it runs

View File

@ -200,6 +200,5 @@ lib/ansible/playbook/base.py pylint:ansible-deprecated-version # 2.18 deprecati
lib/ansible/playbook/play.py pylint:ansible-deprecated-version # 2.18 deprecation
lib/ansible/playbook/play_context.py pylint:ansible-deprecated-version # 2.18 deprecation
lib/ansible/plugins/action/__init__.py pylint:ansible-deprecated-version # 2.18 deprecation
lib/ansible/plugins/loader.py pylint:ansible-deprecated-version # 2.18 deprecation
lib/ansible/template/__init__.py pylint:ansible-deprecated-version # 2.18 deprecation
lib/ansible/vars/manager.py pylint:ansible-deprecated-version # 2.18 deprecation