Production-ready Ansible automation container built from source with Python virtual environment isolation and automatic dependency monitoring. Runs as non-root user with multi-mode entrypoint support.
Every build ships a Sigstore-signed SBOM and a full Trivy scan — verify them yourself, no login required:
gh attestation verify oci://ghcr.io/oorabona/ansible:latest --owner oorabona
Full walkthrough (SBOM payload, Trivy findings, multi-arch manifest inspection, upstream dependency tracking) → https://oorabona.github.io/docker-containers/verify-images/
# Pull from GitHub Container Registry
docker pull ghcr.io/oorabona/ansible:latest
# Or from Docker Hub
docker pull oorabona/ansible:latest
# Run a playbook
docker run --rm \
-v ./playbooks:/playbooks:ro \
-v ./inventory:/inventory:ro \
-v ~/.ssh:/home/ansible/.ssh:ro \
ghcr.io/oorabona/ansible playbook /playbooks/site.yml -i /inventory/hosts
# Check version
docker run --rm ghcr.io/oorabona/ansible ansible --version
/opt/ansible-venv for clean separationansible user for security (with sudo access if needed)inotifywait monitors requirements.txt and requirements.yml for changesansible with UID 1000)requirements.ymlrequirements.txtThe container supports multiple execution modes via the entrypoint:
Run an Ansible playbook:
docker run --rm \
-v ./playbooks:/playbooks:ro \
ghcr.io/oorabona/ansible playbook /playbooks/site.yml -i /inventory/hosts
Interact with Ansible Vault:
docker run --rm \
-v ./secrets:/secrets \
ghcr.io/oorabona/ansible vault encrypt /secrets/password.yml
Execute a shell script:
docker run --rm \
-v ./scripts:/scripts:ro \
ghcr.io/oorabona/ansible run-script /scripts/setup.sh
Execute any command directly:
docker run --rm ghcr.io/oorabona/ansible ansible-galaxy collection list
docker run --rm ghcr.io/oorabona/ansible ansible-inventory --list
| Argument | Description | Default |
|---|---|---|
VERSION | Ansible version to install | latest |
UPSTREAM_VERSION | Raw version for pip (without suffix) | Uses VERSION if not set |
OS_VERSION | Ubuntu base image version | latest |
PYASN1_VERSION | pyasn1 package version | 0.6.2 |
PARAMIKO_VERSION | Paramiko SSH library version | 4.0.0 |
CFFI_VERSION | CFFI package version | 2.0.0 |
CRYPTOGRAPHY_VERSION | Cryptography library version | 46.0.4 |
PYCRYPTODOME_VERSION | PyCryptodome package version | 3.23.0 |
PYNACL_VERSION | PyNaCl package version | 1.6.2 |
Example build with specific versions:
docker build \
--build-arg VERSION=2.16.1 \
--build-arg OS_VERSION=24.04 \
--build-arg CRYPTOGRAPHY_VERSION=46.0.4 \
-t ansible:2.16.1 .
| Variable | Description | Default |
|---|---|---|
ADDONSCRIPT | Path to custom initialization script | (unset — no script runs) |
WAIT_BEFORE_EXIT | Wait for keypress before container exits | (unset) |
VIRTUAL_ENV | Python virtual environment path | /opt/ansible-venv |
PATH | Updated to include venv binaries | /opt/ansible-venv/bin:$PATH |
The ADDONSCRIPT environment variable points to a script that runs before the main command. Use it for custom initialization:
services:
ansible:
image: ghcr.io/oorabona/ansible:latest
environment:
ADDONSCRIPT: /scripts/init-aws-credentials.sh
volumes:
- ./scripts:/scripts:ro
Nothing runs when it is unset or empty, which is the default. A value naming something that is not executable stops the container with a message. Anything executable is sourced — and note that a directory is executable, so a path that points at one is sourced, fails, and the container carries on: the check is a guard against a typo, not a validation of the script.
The image also carries /addon.sh, the example from this repository. It is not
the default and nothing runs it unless you name it.
Useful for debugging or interactive sessions. Container will wait for Enter key before exiting:
docker run --rm -it \
-e WAIT_BEFORE_EXIT=1 \
ghcr.io/oorabona/ansible ansible-playbook /playbooks/debug.yml
| Path | Purpose | Recommended Mount |
|---|---|---|
/home/ansible/playbook | Working directory | Read-only for playbooks |
/home/ansible/.ansible | Ansible collections and plugins | Persistent volume |
/home/ansible/.ssh | SSH keys for remote connections | Read-only, mode 600 |
/etc/ansible | Ansible configuration | Read-only override |
services:
ansible:
image: ghcr.io/oorabona/ansible:latest
volumes:
- ./playbooks:/playbooks:ro
- ./inventory:/inventory:ro
- ~/.ssh:/home/ansible/.ssh:ro
- ansible_collections:/home/ansible/.ansible
working_dir: /playbooks
command: playbook site.yml -i /inventory/hosts
volumes:
ansible_collections:
The container automatically watches for changes to dependency files:
services:
ansible:
image: ghcr.io/oorabona/ansible:latest
volumes:
- ./playbooks:/playbooks:ro
- ./requirements.yml:/home/ansible/playbook/requirements.yml:ro
- ./requirements.txt:/home/ansible/playbook/requirements.txt:ro
- ansible_collections:/home/ansible/.ansible
command: playbook /playbooks/site.yml
volumes:
ansible_collections:
When requirements.yml or requirements.txt changes, the container automatically installs updates.
ansible user (UID 1000, GID 1000)services:
ansible:
image: ghcr.io/oorabona/ansible:latest
read_only: true
tmpfs:
- /tmp
- /run
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
volumes:
- ./playbooks:/playbooks:ro
- ./inventory:/inventory:ro
- ~/.ssh:/home/ansible/.ssh:ro
:ro)# Set proper permissions before mounting
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
# Run with SSH agent forwarding (if supported by Docker setup)
docker run --rm \
-v $SSH_AUTH_SOCK:/ssh-agent \
-e SSH_AUTH_SOCK=/ssh-agent \
-v ./playbooks:/playbooks:ro \
ghcr.io/oorabona/ansible playbook /playbooks/site.yml
Never hardcode secrets in playbooks. Use Ansible Vault or external secret management:
# Encrypt sensitive variables
docker run --rm -it \
-v ./vars:/vars \
ghcr.io/oorabona/ansible vault encrypt /vars/secrets.yml
# Run playbook with vault password
docker run --rm \
-v ./playbooks:/playbooks:ro \
-v ./vars:/vars:ro \
-e ANSIBLE_VAULT_PASSWORD_FILE=/vars/.vault_pass \
ghcr.io/oorabona/ansible playbook /playbooks/site.yml
All Python cryptography and SSH dependencies are pinned and monitored for updates via PyPI:
| Dependency | Version | Type | Purpose |
|---|---|---|---|
| pyasn1 | 0.6.2 | PyPI | ASN.1 types and codecs |
| Paramiko | 4.0.0 | PyPI | SSH protocol implementation |
| cffi | 2.0.0 | PyPI | C Foreign Function Interface |
| cryptography | 46.0.4 | PyPI | Cryptographic recipes and primitives |
| pycryptodome | 3.23.0 | PyPI | Cryptographic library (replaces deprecated pycrypto) |
| PyNaCl | 1.6.2 | PyPI | Python bindings to libsodium |
All dependencies are automatically monitored via the upstream monitoring workflow. When new versions are released on PyPI:
The container uses modern cryptographic libraries:
pycrypto packageSupported platforms:
Built from source due to installation issues with pip on ARM platforms. Multi-stage build ensures minimal final image size.
ubuntu:{OS_VERSION}
├── Runtime packages (python3, openssh-client, inotify-tools, etc.)
├── Python venv (/opt/ansible-venv)
│ ├── ansible=={VERSION}
│ ├── cryptography=={VERSION}
│ ├── paramiko=={VERSION}
│ └── ... (all dependencies)
├── User setup (ansible user + sudo access)
└── Entrypoint scripts
Content type
Image
Digest
sha256:76a32efc3…
Size
261.7 MB
Last updated
1 day ago
docker pull oorabona/ansible