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

pull/85819/head
Matt Clay 3 months ago committed by GitHub
parent f29d432c69
commit a25fd1021a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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

@ -124,6 +124,8 @@ def delegate(args: CommonConfig, host_state: HostState, exclude: list[str], requ
@contextlib.contextmanager @contextlib.contextmanager
def metadata_context(args: EnvironmentConfig) -> t.Generator[None]: def metadata_context(args: EnvironmentConfig) -> t.Generator[None]:
"""A context manager which exports delegation metadata.""" """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: 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_path = os.path.join(ResultType.TMP.relative_path, os.path.basename(metadata_fd.name))
args.metadata.to_file(args.metadata_path) args.metadata.to_file(args.metadata_path)

Loading…
Cancel
Save