Skip to content

TimGrt/docker-rhel8-ansible

Repository files navigation

RHEL 8 Ansible Test Image

RHEL 8 Docker container for Ansible playbook and role testing.
This container is used to test Ansible roles and playbooks (e.g. with molecule) running locally inside the container.
A user ansible is created with password-less sudo configured.

Docker Build and Publish Docker Pulls CodeFactor Grade

How to Build

If you need to build the image on your own locally, do the following:

  1. Install container runtime, I use Podman but you may also use Docker.
  2. Clone the repository and cd into this directory.
  3. Run podman build -t rhel8-ansible .

How to Use Standalone

  1. Install container runtime, I use Podman. You may also use Docker, but you'll have to adjust some configurations.

  2. Pull this image from Docker Hub or use the image you built earlier, e.g. called rhel8-ansible:latest for the next step.

    podman pull timgrt/rhel8-ansible:latest
  3. Run a container from the image.

    podman run --detach --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro --name instance timgrt/rhel8-ansible:latest
  4. Use the container in your inventory with the podman connection plugin.

    [test]
    instance ansible_connection=podman ansible_user=ansible

    Using the ansible user inside the container to be able to test with become.

    You'll need to have the Ansible collection containers.podman installed.

    ansible-galaxy collection install containers.podman

How to Use with Molecule

  1. Install Docker.

  2. Install Molecule.

  3. Add Image in molecule.yml.

    ---
    driver:
      name: podman
    platforms:
      - name: rhel8
        image: docker.io/timgrt/rhel8-ansible:latest
        volumes:
          - /sys/fs/cgroup:/sys/fs/cgroup:ro
        command: "/usr/sbin/init"
        pre_build_image: true
    provisioner:
      name: ansible
      config_options:
        defaults:
          interpreter_python: auto_silent
          callback_result_format: yaml
        ssh_connection:
          pipelining: false
      inventory:
        host_vars:
          rhel8:
            ansible_user: ansible

Author

Created 2022 by Tim Grützmacher, inspired by Jeff Geerling

About

RHEL 8 Docker Image for Ansible testing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published