feat(container): support binary download and bind-mount into containers#50
Merged
Conversation
Container setup mode now reuses the shared download-binary task when binary_url is set, bind-mounts destination_directory into the container (via optional binary_app_path), and cleans up binary artifacts on uninstall. Adds a container-binary Molecule scenario and documents the new variables in README. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Use debian:bookworm-slim for glibc binary compatibility, a dedicated /opt/binaries mount path, and sleep infinity to keep the container running. Verify binary presence via mount inspection and docker exec instead of the docker:// testinfra backend, which fails when the container is restarting. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Alpine is already exercised in other container scenarios on CI. Use a YAML list command so Ansible passes sleep/infinity correctly to docker_container, and relax the mount assertion to avoid brittle source-path checks. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Pass module arguments via a combined dict so list-style commands (e.g. [/bin/sleep, infinity]) are not stringified by Jinja quoting. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Testinfra mis-detects OS on Alpine via the docker:// backend. Verify mounts with docker inspect and execution with docker exec instead. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
…nary Molecule dind scenarios mount the host Docker socket, so bind-mount sources must exist on the runner host—not only inside the instance container filesystem. Mount /tmp/molecule-binary through the instance and use alpine:3.18 as the basic runtime image. Co-authored-by: Ahmad <zer0ne.io.x@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Container deploy mode (
setup_mode: container) now supports downloading a binary or archive from a URL and bind-mounting it into a container for execution — while still using a specified base image.This brings container mode in line with the existing
binary_url,binary_strip_components,binary_file_name_override, anddestination_directoryvariables already used by systemd and install modes.Changes
tasks/container/setup.ymlincludes the shareddownload-binary.ymltask whenbinary_urlis setfacts-container.ymlbind-mountsdestination_directoryinto the container atbinary_app_path(defaults todestination_directory)setup_mode: containercontainer-binaryMolecule scenario (jq static binary in Alpine)container-binaryto the Molecule matrixdocker/requests/urllib3inprepare-docker.ymlsocommunity.dockerworks inside dind instancesUsage example
Testing
yamllintandansible-lintpass/usr/local/bin, executed successfully inside Alpine containercontainer-binaryscenario added (runs in CI onubuntu-latest)