Skip to content

pad92/docker-ansible-alpine

 
 

Repository files navigation

Docker-Ansible base image

Pipeline version Docker Pulls Docker Image Size Docker Stars

Usage

Environnement variable

Variable Default Value Usage
PIP_REQUIREMENTS requirements.txt install python library requirements
ANSIBLE_REQUIREMENTS requirements.yml install ansible galaxy roles requirements
DEPLOY_KEY pass an SSH private key to use in container
CA_CERT_UPGRADE set to true to update ca-certificates package

Mitogen

To enable mitogen, add this configuration into defaults in ansible.cfg file (adjust the Python version path if using a custom Alpine base):

[defaults]
strategy_plugins = /usr/lib/python3.14/site-packages/ansible_mitogen/plugins/strategy
strategy = mitogen_linear

Full documentation : https://mitogen.networkgenomics.com/ansible_detailed.html

Run Playbook

docker run -it --rm \
  -v ${PWD}:/ansible \
  pad92/ansible-alpine:latest \
  ansible-playbook -i inventory playbook.yml

Generate Base Role structure

docker run -it --rm \
  -v ${PWD}:/ansible \
  pad92/ansible-alpine:latest \
  ansible-galaxy init role-name

Lint Role

docker run -it --rm \
  -v ${PWD}:/ansible \
  pad92/ansible-alpine:latest \
  ansible-lint tests/playbook.yml

Run with forwarding ssh agent

docker run -it --rm \
  -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent \
  -v ${PWD}:/ansible \
  -e SSH_AUTH_SOCK=/ssh-agent \
  pad92/ansible-alpine:latest \
  sh

Add custom CA certificates

docker run -it --rm \
  -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent \
  -v ${PWD}:/ansible \
  -v ${PWD}/ca-certificates:/usr/local/share/ca-certificates \
  -e SSH_AUTH_SOCK=/ssh-agent \
  pad92/ansible-alpine:latest sh

Local Development and Testing

A Makefile is provided to build and run the test suite locally, matching the steps and variables configured in .gitlab-ci.yml.

Build the Image

To build the Docker image locally and load it directly into your local Docker daemon storage (no registry push):

make build

Run All Tests

To run all tests (Ansible functional checks, Mitogen imports, and Trivy security scans):

make test

Note: The Trivy scan mounts your host's /var/run/docker.sock to scan the locally built image without pulling it, and persists its database to ./trivy-cache.

Run Specific Test Targets

You can also run specific test jobs individually:

make test-ansible    # Run ansible and ansible-lint checks
make test-mitogen    # Run mitogen import verification
make test-trivy      # Run Trivy vulnerability scan

Cleanup

To remove the local Trivy cache database and clean up buildx configurations:

make clean

About

docker ansible container based on Alpine Linux

Resources

License

Stars

45 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages

  • Makefile 49.2%
  • Dockerfile 26.5%
  • Shell 24.3%