From a2dda41bb66113ed2cc14a550cf882ef3542df1e Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Wed, 5 Nov 2025 19:25:49 +0100 Subject: [PATCH] Removed deprecated handle_stats_and_callbacks param of _load_included_file (#86063) * Removed deprecated handle_stats_and_callbacks param of _load_included_file Fixes #86003 * ci_complete --- ...-deprecated-handle_stats_and_callbacks.yml | 2 ++ lib/ansible/plugins/strategy/__init__.py | 24 +------------------ lib/ansible/plugins/strategy/free.py | 1 - lib/ansible/plugins/strategy/linear.py | 1 - test/sanity/ignore.txt | 1 - 5 files changed, 3 insertions(+), 26 deletions(-) create mode 100644 changelogs/fragments/86003-remove-deprecated-handle_stats_and_callbacks.yml diff --git a/changelogs/fragments/86003-remove-deprecated-handle_stats_and_callbacks.yml b/changelogs/fragments/86003-remove-deprecated-handle_stats_and_callbacks.yml new file mode 100644 index 00000000000..3bd13b19ff4 --- /dev/null +++ b/changelogs/fragments/86003-remove-deprecated-handle_stats_and_callbacks.yml @@ -0,0 +1,2 @@ +removed_features: + - Removed deprecated ``handle_stats_and_callbacks`` parameter of the ``StrategyBase._load_included_file`` method. (https://github.com/ansible/ansible/issues/86003) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 28d271186b6..39b3851125a 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -815,7 +815,7 @@ class StrategyBase: return ti_copy - def _load_included_file(self, included_file: IncludedFile, iterator, is_handler=False, handle_stats_and_callbacks=True): + def _load_included_file(self, included_file: IncludedFile, iterator, is_handler=False): """ Loads an included YAML file of tasks, applying the optional set of variables. @@ -823,15 +823,6 @@ class StrategyBase: in such case the caller is responsible for marking the host(s) as failed using PlayIterator.mark_host_failed(). """ - if handle_stats_and_callbacks: - display.deprecated( - msg="Reporting play recap stats and running callbacks functionality for " - "``include_tasks`` in ``StrategyBase._load_included_file`` is deprecated. " - "See ``https://github.com/ansible/ansible/pull/79260`` for guidance on how to " - "move the reporting into specific strategy plugins to account for " - "``include_role`` tasks as well.", - version="2.21", - ) display.debug("loading included file: %s" % included_file._filename) try: data = self._loader.load_from_file(included_file._filename, trusted_as_template=True) @@ -851,9 +842,6 @@ class StrategyBase: loader=self._loader, variable_manager=self._variable_manager, ) - if handle_stats_and_callbacks: - for host in included_file._hosts: - self._tqm._stats.increment('ok', host.name) except AnsibleParserError: raise except AnsibleError as e: @@ -861,18 +849,8 @@ class StrategyBase: reason = "Could not find or access '%s' on the Ansible Controller." % to_text(e.file_name) else: reason = to_text(e) - if handle_stats_and_callbacks: - for tr in included_file._results: - tr._return_data['failed'] = True - - for host in included_file._hosts: - tr = _RawTaskResult(host=host, task=included_file._task, return_data=dict(failed=True, reason=reason), task_fields={}) - self._tqm._stats.increment('failures', host.name) - self._tqm.send_callback('v2_runner_on_failed', tr) raise AnsibleError(reason) from e - if handle_stats_and_callbacks: - self._tqm.send_callback('v2_playbook_on_include', included_file) display.debug("done processing included file") return block_list diff --git a/lib/ansible/plugins/strategy/free.py b/lib/ansible/plugins/strategy/free.py index f0e4bfe61d0..d2ddb07ecfd 100644 --- a/lib/ansible/plugins/strategy/free.py +++ b/lib/ansible/plugins/strategy/free.py @@ -240,7 +240,6 @@ class StrategyModule(StrategyBase): included_file, iterator=iterator, is_handler=is_handler, - handle_stats_and_callbacks=False, ) # let PlayIterator know about any new handlers included via include_role or diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index a9a579efb08..7415e1bdbe3 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -250,7 +250,6 @@ class StrategyModule(StrategyBase): included_file, iterator=iterator, is_handler=is_handler, - handle_stats_and_callbacks=False, ) # let PlayIterator know about any new handlers included via include_role or diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index d6eeccddafa..2c3e8ae96fb 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -230,5 +230,4 @@ test/integration/targets/ansible-test-sanity-pylint/deprecated_thing.py pylint:a test/integration/targets/ansible-test-sanity-pylint/deprecated_thing.py pylint:ansible-deprecated-collection-name-not-permitted # required to verify plugin against core lib/ansible/module_utils/compat/paramiko.py pylint:ansible-deprecated-version # TODO: 2.21 lib/ansible/plugins/connection/paramiko_ssh.py pylint:ansible-deprecated-version # TODO: 2.21 -lib/ansible/plugins/strategy/__init__.py pylint:ansible-deprecated-version # TODO: 2.21 .github/RELEASE_NAMES.txt release-names # TODO: 2.21