Sign inSign up

letompouce/ansible

By letompouce

Updated 5 months ago

Docker image with Ansible & ansible-lint.

Image
0

833

letompouce/ansible repository overview

letompouce/ansible

Ansible images for fun and profit.

Ships with:

  • ansible-core, ansible-lint, ansible-galaxy
  • ssh-client, sshpass
  • git, curl, openssl, sudo, tzdata
  • python helpers: netaddr, paramiko, requests

Base image: python:3.11-slim (Debian Bookworm).

collections

The image ships only with ansible-core (no bundled collections). Install the collections you need at runtime, typically via your project's requirements.yml:

ansible-galaxy collection install -r requirements.yml

This keeps the image small and lets each consumer pin its own collection versions.

molecule variant

A -molecule variant is published alongside the standard image, intended for testing Ansible roles with the Molecule + Docker driver.

Tags: latest-molecule, head-molecule, <gittag>-molecule.

On top of the base image, it adds:

  • apt: docker-cli (CLI only — no daemon, talks to a mounted host socket), rsync
  • pip: molecule, molecule-plugins[docker], docker
  • collections (system-wide, /usr/share/ansible/collections): community.docker, ansible.posix, community.general

The ansible user is added to the docker group at build time. To talk to a Docker socket mounted from the host, you typically also need to align the group at runtime:

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --group-add $(stat -c '%g' /var/run/docker.sock) \
    -v $(pwd):/src \
    letompouce/ansible:latest-molecule \
    molecule test

build

Default versions: ANSIBLE_CORE_VERSION=2.16.0, ANSIBLELINT_VERSION=24.10.0.

Override versions:

docker build \
    --build-arg ANSIBLE_CORE_VERSION=2.16.0 \
    --build-arg ANSIBLELINT_VERSION=24.10.0 \
    -t letompouce/ansible:2.16 \
    .

run

Basic invocation:

docker run --rm letompouce/ansible ansible --version

WORKDIR is /src/.

Mount a local playbook:

docker run --rm \
    -v $(pwd):/src \
    letompouce/ansible \
    ansible-playbook --syntax-check playbook/site.yml

Use the host's timezone:

docker run --rm \
    -v /etc/localtime:/etc/localtime:ro \
    letompouce/ansible \
    ansible --version

Use an arbitrary timezone:

docker run --rm \
    -e 'TZ=Europe/Paris' \
    letompouce/ansible \
    ansible --version

more

Tag summary

Content type

Image

Digest

sha256:33902effc

Size

111.7 MB

Last updated

5 months ago

docker pull letompouce/ansible