Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Ansible in a container. Composition of templates + a script to render values onto Dockerfiles. Used to execute Ansible roles in Docker, e.g. CI, ephemeral runners.

License

Notifications You must be signed in to change notification settings

macunha1/ansible-container-images

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Container Images

GitHub Workflow Status

Summary

Repository name in Docker Hub: macunha1/ansible

This repository contains Jinja2 templates to specify Dockerfiles for multiple Linux distros, these templates are rendered and then dynamically build by GitHub Actions. Therefore, it is the composition of: templates + a script to render + the CI pipeline to build and push the images.

Base OS

By default the following Linux distros are implemented. However, any future (version) release of any one of the supported distro can be easily added in the config to render a new Dockerfile.

  • Debian: 10 (buster), 11 (bullseye);
  • Ubuntu: 20.04, 22.04, 22.10;
  • Alpine 3.10, 3.15, 3.16;

Pending: OpenSUSE and Fedora.

Usage

Ansible will be installed with the version specified on config. All Docker images had Ansible installed through pip.

To make sure the right version of Ansible is installed on container during execution of tests, run a pip install ansible==$DESIRED_VERSION.

Quick

Here comes a simplest working example:

FROM macunha1/ansible:alpine-3.11.5

RUN pip install ansible==2.3.4

ENTRYPOINT ["ansible-playbook"]
CMD ["-i", "inventory/awesome", "playbook.yml"]

Then,

docker build -f /path/to/Dockerfile -t awesome/docker-ansible:tag /any/build/context

Enjoy your Ansible image.

Super quick

If you want to go directly to the point, without building your own custom image, just run:

docker run -it --name awesome-ansible-container \
  -v ${HOME}/.ssh:/root/.ssh:ro \
  # ... additional configurations
  macunha1/ansible:alpine-3.11.5 \
  -- -i inventory/awesome playbook.yml

Why yet another Ansible image for Docker?

There has been quite a few Ansible images for Docker (e.g., search in the Docker Hub), so why reinvent the wheel?

Simply, because most of them seems to be abadoned. Even the base of this fork from William Yeh

Motivation

This repository was first created to give Confluent Kafka role a proper test suite. Previously, public images gave me a lot of issues, and I got tired of making workarounds to have a CI working for my roles.

If you're tired too of looking around and not finding what you need, join me and use these Docker images. Feel free to open issues and send PR, I will be happy to colaborate.

Use cases

With Docker, we can test any Ansible playbook against any version of any Linux distribution without the help of Vagrant. More lightweight, and more portable across IaaS providers.

If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more quicker setup to test your Ansible playbooks.

Contribute

PRs Welcome

Feel free to fill an issue containing feature request(s), or (even better) to send me a Pull request, I would be happy to collaborate with you.

If this role didn't work for you, or if you found some bug during the execution, let me know.

About

Ansible in a container. Composition of templates + a script to render values onto Dockerfiles. Used to execute Ansible roles in Docker, e.g. CI, ephemeral runners.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published