ansible-core 2.15.1__py3-none-any.whl → 2.15.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansible-core might be problematic. Click here for more details.
- ansible/config/manager.py +1 -1
- ansible/galaxy/collection/__init__.py +12 -15
- ansible/module_utils/ansible_release.py +1 -1
- ansible/modules/apt_key.py +8 -5
- ansible/modules/apt_repository.py +2 -0
- ansible/modules/dnf5.py +5 -7
- ansible/modules/find.py +3 -0
- ansible/modules/validate_argument_spec.py +1 -1
- ansible/plugins/action/template.py +26 -15
- ansible/plugins/connection/paramiko_ssh.py +8 -0
- ansible/plugins/connection/psrp.py +3 -3
- ansible/plugins/connection/ssh.py +19 -2
- ansible/plugins/filter/comment.yml +1 -1
- ansible/plugins/filter/split.yml +1 -1
- ansible/plugins/filter/to_yaml.yml +1 -1
- ansible/plugins/lookup/template.py +11 -6
- ansible/plugins/strategy/__init__.py +20 -12
- ansible/plugins/test/change.yml +1 -1
- ansible/plugins/test/changed.yml +1 -1
- ansible/plugins/test/reachable.yml +1 -1
- ansible/plugins/test/succeeded.yml +1 -1
- ansible/plugins/test/success.yml +1 -1
- ansible/plugins/test/successful.yml +1 -1
- ansible/plugins/test/unreachable.yml +1 -1
- ansible/release.py +1 -1
- ansible/template/__init__.py +38 -24
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/METADATA +1 -1
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/RECORD +43 -43
- ansible_test/_data/completion/remote.txt +2 -1
- ansible_test/_internal/__init__.py +7 -0
- ansible_test/_internal/commands/integration/cloud/__init__.py +2 -2
- ansible_test/_internal/commands/sanity/validate_modules.py +2 -2
- ansible_test/_internal/containers.py +2 -2
- ansible_test/_internal/coverage_util.py +2 -2
- ansible_test/_internal/payload.py +2 -2
- ansible_test/_internal/provisioning.py +5 -2
- ansible_test/_internal/pypi_proxy.py +4 -4
- ansible_test/_internal/util_common.py +38 -6
- {ansible_core-2.15.1.data → ansible_core-2.15.2.data}/scripts/ansible-test +0 -0
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/COPYING +0 -0
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/WHEEL +0 -0
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/entry_points.txt +0 -0
- {ansible_core-2.15.1.dist-info → ansible_core-2.15.2.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Common utility code that depends on CommonConfig."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
-
import atexit
|
|
5
4
|
import collections.abc as c
|
|
6
5
|
import contextlib
|
|
7
6
|
import json
|
|
@@ -64,6 +63,39 @@ from .host_configs import (
|
|
|
64
63
|
CHECK_YAML_VERSIONS: dict[str, t.Any] = {}
|
|
65
64
|
|
|
66
65
|
|
|
66
|
+
class ExitHandler:
|
|
67
|
+
"""Simple exit handler implementation."""
|
|
68
|
+
_callbacks: list[tuple[t.Callable, tuple[t.Any, ...], dict[str, t.Any]]] = []
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def register(func: t.Callable, *args, **kwargs) -> None:
|
|
72
|
+
"""Register the given function and args as a callback to execute during program termination."""
|
|
73
|
+
ExitHandler._callbacks.append((func, args, kwargs))
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
@contextlib.contextmanager
|
|
77
|
+
def context() -> t.Generator[None, None, None]:
|
|
78
|
+
"""Run all registered handlers when the context is exited."""
|
|
79
|
+
last_exception: BaseException | None = None
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
yield
|
|
83
|
+
finally:
|
|
84
|
+
queue = list(ExitHandler._callbacks)
|
|
85
|
+
|
|
86
|
+
while queue:
|
|
87
|
+
func, args, kwargs = queue.pop()
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
func(*args, **kwargs)
|
|
91
|
+
except BaseException as ex: # pylint: disable=broad-exception-caught
|
|
92
|
+
last_exception = ex
|
|
93
|
+
display.fatal(f'Exit handler failed: {ex}')
|
|
94
|
+
|
|
95
|
+
if last_exception:
|
|
96
|
+
raise last_exception
|
|
97
|
+
|
|
98
|
+
|
|
67
99
|
class ShellScriptTemplate:
|
|
68
100
|
"""A simple substitution template for shell scripts."""
|
|
69
101
|
|
|
@@ -211,7 +243,7 @@ def process_scoped_temporary_file(args: CommonConfig, prefix: t.Optional[str] =
|
|
|
211
243
|
else:
|
|
212
244
|
temp_fd, path = tempfile.mkstemp(prefix=prefix, suffix=suffix)
|
|
213
245
|
os.close(temp_fd)
|
|
214
|
-
|
|
246
|
+
ExitHandler.register(lambda: os.remove(path))
|
|
215
247
|
|
|
216
248
|
return path
|
|
217
249
|
|
|
@@ -222,7 +254,7 @@ def process_scoped_temporary_directory(args: CommonConfig, prefix: t.Optional[st
|
|
|
222
254
|
path = os.path.join(tempfile.gettempdir(), f'{prefix or tempfile.gettempprefix()}{generate_name()}{suffix or ""}')
|
|
223
255
|
else:
|
|
224
256
|
path = tempfile.mkdtemp(prefix=prefix, suffix=suffix)
|
|
225
|
-
|
|
257
|
+
ExitHandler.register(lambda: remove_tree(path))
|
|
226
258
|
|
|
227
259
|
return path
|
|
228
260
|
|
|
@@ -296,7 +328,7 @@ def get_injector_path() -> str:
|
|
|
296
328
|
"""Remove the temporary injector directory."""
|
|
297
329
|
remove_tree(injector_path)
|
|
298
330
|
|
|
299
|
-
|
|
331
|
+
ExitHandler.register(cleanup_injector)
|
|
300
332
|
|
|
301
333
|
return injector_path
|
|
302
334
|
|
|
@@ -354,7 +386,7 @@ def get_python_path(interpreter: str) -> str:
|
|
|
354
386
|
verified_chmod(python_path, MODE_DIRECTORY)
|
|
355
387
|
|
|
356
388
|
if not PYTHON_PATHS:
|
|
357
|
-
|
|
389
|
+
ExitHandler.register(cleanup_python_paths)
|
|
358
390
|
|
|
359
391
|
PYTHON_PATHS[interpreter] = python_path
|
|
360
392
|
|
|
@@ -364,7 +396,7 @@ def get_python_path(interpreter: str) -> str:
|
|
|
364
396
|
def create_temp_dir(prefix: t.Optional[str] = None, suffix: t.Optional[str] = None, base_dir: t.Optional[str] = None) -> str:
|
|
365
397
|
"""Create a temporary directory that persists until the current process exits."""
|
|
366
398
|
temp_path = tempfile.mkdtemp(prefix=prefix or 'tmp', suffix=suffix or '', dir=base_dir)
|
|
367
|
-
|
|
399
|
+
ExitHandler.register(remove_tree, temp_path)
|
|
368
400
|
return temp_path
|
|
369
401
|
|
|
370
402
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|