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

Do not strip file from container_volume_mounts #1410

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/ansible_runner/config/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ def _update_volume_mount_paths(self,
args_list: list[str],
src_mount_path: str | None,
dst_mount_path: str | None = None,
labels: str | None = None
labels: str | None = None,
strip_file: bool = True,
) -> None:

if src_mount_path is None or not os.path.exists(src_mount_path):
Expand All @@ -417,10 +418,12 @@ def _update_volume_mount_paths(self,
else:
dst_path = os.path.abspath(os.path.expanduser(os.path.expandvars(dst_mount_path)))

src_is_dir = os.path.isdir(src_path)

# ensure each is a directory not file, use src for dest
# because dest doesn't exist locally
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)
src_dir = src_path if src_is_dir else os.path.dirname(src_path)
dst_dir = dst_path if src_is_dir else os.path.dirname(dst_path)

# always ensure a trailing slash
src_dir = os.path.join(src_dir, "")
Expand All @@ -432,7 +435,10 @@ def _update_volume_mount_paths(self,
self._ensure_path_safe_to_mount(dst_dir)

# format the src dest str
volume_mount_path = f"{src_dir}:{dst_dir}"
if strip_file or src_is_dir:
volume_mount_path = f"{src_dir}:{dst_dir}"
else:
volume_mount_path = f"{src_path}:{dst_path}"

# add labels as needed
if labels:
Expand Down Expand Up @@ -571,7 +577,7 @@ def wrap_args_for_containerization(self,
labels = None
if len(volume_mounts) == 3:
labels = f":{volume_mounts[2]}"
self._update_volume_mount_paths(new_args, volume_mounts[0], dst_mount_path=volume_mounts[1], labels=labels)
self._update_volume_mount_paths(new_args, volume_mounts[0], dst_mount_path=volume_mounts[1], labels=labels, strip_file=False)

# Reference the file with list of keys to pass into container
# this file will be written in ansible_runner.runner
Expand Down
Loading