docker.ansible#
Container image arillso/ansible: ansible-core in a Python virtualenv on
Alpine Linux, with SSH, Kubernetes and helper CLI tools. All facts on this page
come from Dockerfile, requirements.txt and .github/workflows/ in
https://github.com/arillso/docker.ansible (branch main).
Image Facts#
Property |
Value |
|---|---|
Base image |
|
ansible-core |
|
Python |
Alpine package |
User |
|
Working directory |
|
Entrypoint |
|
Default command |
|
Stop signal |
|
Platforms |
|
License |
MIT |
Contents#
System Packages#
Installed with apk in the production stage of the Dockerfile:
Area |
Packages |
|---|---|
Runtime |
|
SSH and transfer |
|
Kubernetes |
|
Utilities |
|
Python Packages#
Installed from requirements.txt into /pipx/venvs/ansible (selection, see
the file for exact pins):
Area |
Packages |
|---|---|
Ansible |
|
Connections |
|
Cloud |
|
Containers |
|
Databases |
|
Other APIs |
|
Built-in Ansible Configuration#
The image writes /etc/ansible/ansible.cfg and /etc/ansible/hosts.yml:
Setting |
Value |
|---|---|
|
|
|
|
|
Path of the Mitogen strategy plugins; the default strategy stays
|
|
|
|
|
ANSIBLE_FORCE_COLOR=True is set as environment variable.
Mitogen is installed but not active. Enable it per run with
ANSIBLE_STRATEGY=mitogen_linear.
Usage#
# Print the Ansible version (default command)
docker run --rm arillso/ansible
# Run a playbook from the current directory
docker run --rm -v "$(pwd)":/workspace -w /workspace \
arillso/ansible ansible-playbook -i inventory.yml playbook.yml
# Interactive shell
docker run --rm -it -v "$(pwd)":/workspace -w /workspace \
arillso/ansible bash
SSH key and host key checking:
docker run --rm \
-e ANSIBLE_HOST_KEY_CHECKING=True \
-v "$(pwd)":/workspace -w /workspace \
-v "$HOME/.ssh/id_ed25519":/home/ansible/.ssh/id_ed25519:ro \
arillso/ansible ansible-playbook -i inventory.yml playbook.yml
Vault password from a file:
docker run --rm \
-v "$(pwd)":/workspace -w /workspace \
-v "$(pwd)/.vault_pass":/home/ansible/.vault_pass:ro \
arillso/ansible ansible-playbook \
--vault-password-file /home/ansible/.vault_pass playbook.yml
With Mitogen:
docker run --rm -e ANSIBLE_STRATEGY=mitogen_linear \
-v "$(pwd)":/workspace -w /workspace \
arillso/ansible ansible-playbook -i inventory.yml playbook.yml
Files written to a bind mount belong to UID 1000. To write as the calling user,
add --user "$(id -u):$(id -g)".
Extending the Image#
/pipx belongs to root; pip on PATH is the virtualenv’s pip.
Switch to root for the install and back to 1000:1000 afterwards:
FROM arillso/ansible:2.22.0
USER root
RUN pip install --no-cache-dir <package>
USER 1000:1000
Building from Source#
git clone https://github.com/arillso/docker.ansible
cd docker.ansible
make ansible-build # build the image
make test-quick # basic checks
make comprehensive-test # all test suites under tests/
docker build -t arillso/ansible:local . works without make. The builder
stage resolves Alpine packages through the pkg.arillso.io proxy.
CI#
Workflow |
Content |
|---|---|
|
Lint, hadolint, image build, container structure tests, secret scan, dependency review |
|
Build and push for |
|
Daily at 02:00 UTC: CodeQL, Trivy scan ( |
See also
action.playbook - GitHub Action built on this image
go.ansible - Go library for running
ansible-playbookCollection Index - Ansible Collections