Test Ansible roles using Molecule and Podman

Click for: original source

I needed to have testing added to Ansible roles. There are various people in the customer organization developing roles, and we want a lightweight, easy to use test process to unify the looks and quality of the roles. By Ilkka Tengvall.

There are some clear benefits of podman for containers and Ansible for tests:

  • Containers are slim and quick
  • Podman requires no root, which makes it easily part of CI/CD
  • Easy testing language

Molecule encourages an approach that results in consistently developed roles that are well-written, easily understood and maintained. Molecule is the official testing framework for Ansible roles. It provides a streamlined way to create a virtualized environment to test the syntax and functionality of a role.

We can use podman as Molecule plugin to spin up tests quickly in containers. And thanks to podman, no root gets hurt during the process. Which means we can put this safely into the CI/CD process, because of everything gets run as a user. Follow the link to full article. You will also get video tutorial and links to example code in a GitHub repository. DevOps rules!

[Read More]

Tags ansible devops infosec tdd cicd