diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
commit | 48e387c5c12026a567eb7b293a3a590241c0cecb (patch) | |
tree | 80f2573be2d7d534b8ac4d2a852fe43f7ac35324 /lib/ansible/executor | |
parent | Releasing progress-linux version 2.16.6-1~progress7.99u1. (diff) | |
download | ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.tar.xz ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.zip |
Merging upstream version 2.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/executor')
-rw-r--r-- | lib/ansible/executor/__init__.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/discovery/python_target.py | 3 | ||||
-rw-r--r-- | lib/ansible/executor/interpreter_discovery.py | 17 | ||||
-rw-r--r-- | lib/ansible/executor/module_common.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/play_iterator.py | 6 | ||||
-rw-r--r-- | lib/ansible/executor/playbook_executor.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/powershell/module_manifest.py | 5 | ||||
-rw-r--r-- | lib/ansible/executor/process/__init__.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/process/worker.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/stats.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/task_executor.py | 5 | ||||
-rw-r--r-- | lib/ansible/executor/task_queue_manager.py | 4 | ||||
-rw-r--r-- | lib/ansible/executor/task_result.py | 5 |
13 files changed, 25 insertions, 44 deletions
diff --git a/lib/ansible/executor/__init__.py b/lib/ansible/executor/__init__.py index ae8ccff..64fee52 100644 --- a/lib/ansible/executor/__init__.py +++ b/lib/ansible/executor/__init__.py @@ -15,6 +15,4 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations diff --git a/lib/ansible/executor/discovery/python_target.py b/lib/ansible/executor/discovery/python_target.py index 7137733..f66588d 100644 --- a/lib/ansible/executor/discovery/python_target.py +++ b/lib/ansible/executor/discovery/python_target.py @@ -4,8 +4,7 @@ # FUTURE: this could be swapped out for our bundled version of distro to move more complete platform # logic to the targets, so long as we maintain Py2.6 compat and don't need to do any kind of script assembly -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import json import platform diff --git a/lib/ansible/executor/interpreter_discovery.py b/lib/ansible/executor/interpreter_discovery.py index c95cf2e..6d10581 100644 --- a/lib/ansible/executor/interpreter_discovery.py +++ b/lib/ansible/executor/interpreter_discovery.py @@ -1,8 +1,7 @@ # Copyright: (c) 2018 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import bisect import json @@ -10,6 +9,7 @@ import pkgutil import re from ansible import constants as C +from ansible.errors import AnsibleError from ansible.module_utils.common.text.converters import to_native, to_text from ansible.module_utils.distro import LinuxDistribution from ansible.utils.display import Display @@ -53,7 +53,7 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): host = task_vars.get('inventory_hostname', 'unknown') res = None platform_type = 'unknown' - found_interpreters = [u'/usr/bin/python'] # fallback value + found_interpreters = [u'/usr/bin/python3'] # fallback value is_auto_legacy = discovery_mode.startswith('auto_legacy') is_silent = discovery_mode.endswith('_silent') @@ -89,7 +89,7 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): action._discovery_warnings.append(u'No python interpreters found for ' u'host {0} (tried {1})'.format(host, bootstrap_python_list)) # this is lame, but returning None or throwing an exception is uglier - return u'/usr/bin/python' + return u'/usr/bin/python3' if platform_type != 'linux': raise NotImplementedError('unsupported platform for extended discovery: {0}'.format(to_native(platform_type))) @@ -106,7 +106,6 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): platform_info = json.loads(res.get('stdout')) distro, version = _get_linux_distro(platform_info) - if not distro or not version: raise NotImplementedError('unable to get Linux distribution/version info') @@ -120,15 +119,15 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): # provide a transition period for hosts that were using /usr/bin/python previously (but shouldn't have been) if is_auto_legacy: - if platform_interpreter != u'/usr/bin/python' and u'/usr/bin/python' in found_interpreters: + if platform_interpreter != u'/usr/bin/python3' and u'/usr/bin/python3' in found_interpreters: if not is_silent: action._discovery_warnings.append( u"Distribution {0} {1} on host {2} should use {3}, but is using " - u"/usr/bin/python for backward compatibility with prior Ansible releases. " + u"/usr/bin/python3 for backward compatibility with prior Ansible releases. " u"See {4} for more information" .format(distro, version, host, platform_interpreter, get_versioned_doclink('reference_appendices/interpreter_discovery.html'))) - return u'/usr/bin/python' + return u'/usr/bin/python3' if platform_interpreter not in found_interpreters: if platform_interpreter not in bootstrap_python_list: @@ -150,6 +149,8 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): return platform_interpreter except NotImplementedError as ex: display.vvv(msg=u'Python interpreter discovery fallback ({0})'.format(to_text(ex)), host=host) + except AnsibleError: + raise except Exception as ex: if not is_silent: display.warning(msg=u'Unhandled error in Python interpreter discovery for host {0}: {1}'.format(host, to_text(ex))) diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py index 3517543..717a398 100644 --- a/lib/ansible/executor/module_common.py +++ b/lib/ansible/executor/module_common.py @@ -16,9 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import ast import base64 diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py index cb82b9f..474b5da 100644 --- a/lib/ansible/executor/play_iterator.py +++ b/lib/ansible/executor/play_iterator.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import fnmatch @@ -429,13 +427,13 @@ class PlayIterator: # might be there from previous flush state.handlers = self.handlers[:] state.update_handlers = False - state.cur_handlers_task = 0 while True: try: task = state.handlers[state.cur_handlers_task] except IndexError: task = None + state.cur_handlers_task = 0 state.run_state = state.pre_flushing_run_state state.update_handlers = True break diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py index 52ad0c0..7c3ac41 100644 --- a/lib/ansible/executor/playbook_executor.py +++ b/lib/ansible/executor/playbook_executor.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/executor/powershell/module_manifest.py b/lib/ansible/executor/powershell/module_manifest.py index 0720d23..99b18e5 100644 --- a/lib/ansible/executor/powershell/module_manifest.py +++ b/lib/ansible/executor/powershell/module_manifest.py @@ -1,8 +1,7 @@ # (c) 2018 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import base64 import errno @@ -11,13 +10,13 @@ import os import pkgutil import random import re +from importlib import import_module from ansible.module_utils.compat.version import LooseVersion from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text -from ansible.module_utils.compat.importlib import import_module from ansible.plugins.loader import ps_module_utils_loader from ansible.utils.collection_loader import resource_from_fqcr diff --git a/lib/ansible/executor/process/__init__.py b/lib/ansible/executor/process/__init__.py index ae8ccff..64fee52 100644 --- a/lib/ansible/executor/process/__init__.py +++ b/lib/ansible/executor/process/__init__.py @@ -15,6 +15,4 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations diff --git a/lib/ansible/executor/process/worker.py b/lib/ansible/executor/process/worker.py index c043137..6c26aed 100644 --- a/lib/ansible/executor/process/worker.py +++ b/lib/ansible/executor/process/worker.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os import sys diff --git a/lib/ansible/executor/stats.py b/lib/ansible/executor/stats.py index 13a053b..a7cc713 100644 --- a/lib/ansible/executor/stats.py +++ b/lib/ansible/executor/stats.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from collections.abc import MutableMapping diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index d20635a..a8e24f5 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -1,8 +1,7 @@ # (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os import pty @@ -225,7 +224,7 @@ class TaskExecutor: if self._task.loop_with: if self._task.loop_with in self._shared_loader_obj.lookup_loader: - # TODO: hardcoded so it fails for non first_found lookups, but thhis shoudl be generalized for those that don't do their own templating + # TODO: hardcoded so it fails for non first_found lookups, but this should be generalized for those that don't do their own templating # lookup prop/attribute? fail = bool(self._task.loop_with != 'first_found') loop_terms = listify_lookup_plugin_terms(terms=self._task.loop, templar=templar, fail_on_undefined=fail, convert_bare=False) diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 3bbf3d5..f6e8c8b 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os import sys diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index 543b860..2690f3a 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -2,8 +2,7 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible import constants as C from ansible.parsing.dataloader import DataLoader @@ -55,7 +54,7 @@ class TaskResult: if 'results' in self._result: results = self._result['results'] # Loop tasks are only considered skipped if all items were skipped. - # some squashed results (eg, yum) are not dicts and can't be skipped individually + # some squashed results (eg, dnf) are not dicts and can't be skipped individually if results and all(isinstance(res, dict) and res.get('skipped', False) for res in results): return True |