ansible-test - Fix traceback on missing tmp dir (#85814)

This commit is contained in:
Matt Clay
2025-09-05 11:15:43 -07:00
committed by GitHub
parent f29d432c69
commit a25fd1021a
2 changed files with 4 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix a traceback that can occur when using delegation before the ansible-test temp directory is created.

View File

@@ -124,6 +124,8 @@ def delegate(args: CommonConfig, host_state: HostState, exclude: list[str], requ
@contextlib.contextmanager
def metadata_context(args: EnvironmentConfig) -> t.Generator[None]:
"""A context manager which exports delegation metadata."""
os.makedirs(ResultType.TMP.path, exist_ok=True)
with tempfile.NamedTemporaryFile(prefix='metadata-', suffix='.json', dir=ResultType.TMP.path) as metadata_fd:
args.metadata_path = os.path.join(ResultType.TMP.relative_path, os.path.basename(metadata_fd.name))
args.metadata.to_file(args.metadata_path)