summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2020-10-14 11:19:13 -0700
committerMatt Clay <matt@mystile.com>2020-10-21 14:18:59 -0700
commit785fa40dc5269be4caa4874448ddff94f5941429 (patch)
tree234db49ee91c04b6b1c361d4aac4176b27b8203f
parent2faf48f5f9e7632ede7306e8e59c05e2a4fbfaf9 (diff)
downloadansible-785fa40dc5269be4caa4874448ddff94f5941429.tar.gz
[stable-2.8] Fix ansible-test Azure Pipelines container auth.
(cherry picked from commit 2ef4b7e07e6a47785544d0b195fe6887b5c4595b) Co-authored-by: Matt Clay <matt@mystile.com>
-rw-r--r--changelogs/fragments/ansible-test-azp-agent-temp-dir.yml2
-rw-r--r--test/runner/lib/ci/azp.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/changelogs/fragments/ansible-test-azp-agent-temp-dir.yml b/changelogs/fragments/ansible-test-azp-agent-temp-dir.yml
new file mode 100644
index 0000000000..7ff9f8d82b
--- /dev/null
+++ b/changelogs/fragments/ansible-test-azp-agent-temp-dir.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - ansible-test - Using the ``--remote`` option on Azure Pipelines now works from a job running in a container.
diff --git a/test/runner/lib/ci/azp.py b/test/runner/lib/ci/azp.py
index d3e0bcd30f..07cb16034c 100644
--- a/test/runner/lib/ci/azp.py
+++ b/test/runner/lib/ci/azp.py
@@ -151,8 +151,14 @@ class AzurePipelinesAuthHelper(CryptographyAuthHelper):
"""
def publish_public_key(self, public_key_pem): # type: (str) -> None
"""Publish the given public key."""
+ try:
+ agent_temp_directory = os.environ['AGENT_TEMPDIRECTORY']
+ except KeyError as ex:
+ raise MissingEnvironmentVariable(name=ex.args[0])
+
# the temporary file cannot be deleted because we do not know when the agent has processed it
- with tempfile.NamedTemporaryFile(prefix='public-key-', suffix='.pem', delete=False) as public_key_file:
+ # placing the file in the agent's temp directory allows it to be picked up when the job is running in a container
+ with tempfile.NamedTemporaryFile(prefix='public-key-', suffix='.pem', delete=False, dir=agent_temp_directory) as public_key_file:
public_key_file.write(to_bytes(public_key_pem))
public_key_file.flush()