Skip to content

feat(container): support binary download and bind-mount into containers#50

Merged
O1ahmad merged 8 commits into
mainfrom
cursor/container-binary-download-e65b
Jun 7, 2026
Merged

feat(container): support binary download and bind-mount into containers#50
O1ahmad merged 8 commits into
mainfrom
cursor/container-binary-download-e65b

Conversation

@O1ahmad

@O1ahmad O1ahmad commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

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, and destination_directory variables already used by systemd and install modes.

Changes

  • Binary download: tasks/container/setup.yml includes the shared download-binary.yml task when binary_url is set
  • Volume mount: facts-container.yml bind-mounts destination_directory into the container at binary_app_path (defaults to destination_directory)
  • Uninstall: Binary cleanup handlers now run for setup_mode: container
  • Docs: README updated with container binary variables and a Prometheus example
  • Tests: New container-binary Molecule scenario (jq static binary in Alpine)
  • CI: Added container-binary to the Molecule matrix
  • Molecule fix: Install pinned docker/requests/urllib3 in prepare-docker.yml so community.docker works inside dind instances

Usage example

setup_mode: container
name: prometheus
image: debian:bookworm-slim
binary_url: https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
binary_strip_components: 1
binary_file_name_override: prometheus
destination_directory: /usr/local/bin
command: /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml

Testing

  • yamllint and ansible-lint pass
  • Manual validation: downloaded jq binary, bind-mounted /usr/local/bin, executed successfully inside Alpine container
  • Molecule container-binary scenario added (runs in CI on ubuntu-latest)
Open in Web Open in Cursor 

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>
@O1ahmad O1ahmad marked this pull request as ready for review June 6, 2026 23:49
cursoragent and others added 7 commits June 6, 2026 23:54
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>
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>
…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>
@O1ahmad O1ahmad merged commit 8d162a4 into main Jun 7, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants