/container-ubuntu-ansible

Ubuntu container used for testing Ansible roles

Primary LanguageDockerfileMIT LicenseMIT

container-ubuntu-ansible

An Ubuntu container used for testing Ansible roles. Can run with systemd as init.

Tags

This repository currently supports the tags latest, kinetic, jammy, focal and bionic.

The tags follow the conventions of the official ubuntu docker image. latest

Podman / Docker example

# Create the container without systemd and log in
podman run --interactive --tty ghcr.io/stegmannb/container-ubuntu-ansible:latest

Podman / Docker systemd example

# Create the container with systemd
podman run --detach --entrypoint /sbin/init --cap-add SYS_ADMIN --volume /sys/fs/cgroup:/sys/fs/cgroup:ro --systemd=true ghcr.io/stegmannb/container-ubuntu-ansible:latest
# Log into the container
podman exec --latest --interactive --tty /bin/bash
# Or use short flags
podman exec -itl /bin/bash

Molecule systemd example

driver:
  name: containers

platforms:
  - name: molecule-ubuntu-systemd
    image: ghcr.io/stegmannb/container-ubuntu-ansible:latest
    groups:
      - ubuntu
    command: /sbin/init
    tmpfs:
      - /run
      - /tmp
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    capabilities:
      - SYS_ADMIN

Molecule example

driver:
  name: containers

platforms:
  - name: molecule-ubuntu-systemd
    image: ghcr.io/stegmannb/container-ubuntu-ansible:latest
    groups:
      - ubuntu

Ansible systemd example

- name: Create Ubuntu test container
  containers.podman.podman_container:
    name: test-ubuntu
    image: ghcr.io/stegmannb/container-ubuntu-ansible:latest
    groups:
      - ubuntu
    command: /sbin/init
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    capabilities:
      - SYS_ADMIN

Ansible example

- name: Create Ubuntu test container
  containers.podman.podman_container:
    name: test-ubuntu
    image: ghcr.io/stegmannb/container-ubuntu-ansible:latest
    groups:
      - ubuntu