Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-runner destroys container_volume_mounts #1409

Open
felixfontein opened this issue Jan 20, 2025 · 0 comments · May be fixed by #1410
Open

ansible-runner destroys container_volume_mounts #1409

felixfontein opened this issue Jan 20, 2025 · 0 comments · May be fixed by #1410
Labels
needs_triage New item that needs to be triaged

Comments

@felixfontein
Copy link

If I want to mount a single file (in this case, a GPG agent socket) into an EE with container_volume_mounts, ansible-runner strips the filename away and tries to mount the whole directory. This results in a non-usable container.

I don't understand why the code in

src_dir = src_path if os.path.isdir(src_path) else os.path.dirname(src_path)
dst_dir = dst_path if os.path.isdir(src_path) else os.path.dirname(dst_path)
# always ensure a trailing slash
src_dir = os.path.join(src_dir, "")
dst_dir = os.path.join(dst_dir, "")
# ensure the src and dest are safe mount points
# after stripping off the file and resolving
self._ensure_path_safe_to_mount(src_dir)
self._ensure_path_safe_to_mount(dst_dir)
# format the src dest str
volume_mount_path = f"{src_dir}:{dst_dir}"
# add labels as needed
if labels:
if not labels.startswith(":"):
volume_mount_path += ":"
volume_mount_path += labels
# check if mount path already added in args list
if volume_mount_path not in args_list:
args_list.extend(["-v", volume_mount_path])
strips off the filename. If the user explicitly specifies a filename, that should be respected.

This is a minimal bugfix:

diff --git a/src/ansible_runner/config/_base.py b/src/ansible_runner/config/_base.py
index 819640d..3711577 100644
--- a/src/ansible_runner/config/_base.py
+++ b/src/ansible_runner/config/_base.py
@@ -432,7 +432,7 @@ class BaseConfig:
         self._ensure_path_safe_to_mount(dst_dir)
 
         # format the src dest str
-        volume_mount_path = f"{src_dir}:{dst_dir}"
+        volume_mount_path = f"{src_path}:{dst_path}"
 
         # add labels as needed
         if labels:
@github-actions github-actions bot added the needs_triage New item that needs to be triaged label Jan 20, 2025
@felixfontein felixfontein linked a pull request Jan 21, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_triage New item that needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant