This GitHub action is designed to test your Ansible role using Molecule.
Inspired by @robertdebock's molecule-action.
This action is compatible with Molecule scenarios employing the podman driver.
For optimal functionality, this action assumes the following structure for your Ansible role (default configuration):
.
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── molecule
│ └── default
│ ├── molecule.yml
│ ├── playbook.yml
│ └── prepare.yml
├── requirements.yml
├── tasks
│ └── main.yml
├── tox.ini # OPTIONAL
└── vars
└── main.yml
If a tox.ini file is present, the role is tested using tox. Tox automatically installs all dependencies specified within the tox.ini file, thus determining the version of molecule utilized.
The Docker Hub namespace where the image is in. Default "iamenr0s"
.
The image you want to run on. Default "almalinux9"
.
The tag of the container image to use. Default "latest"
.
The options to pass to tox
. For example parallel
. Default ""
. (empty)
The molecule command to use. For example create
. Default "test"
.
The molecule scenario to run. Default "default"
None.
---
on:
- push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: "${{ github.repository }}"
- name: molecule
uses: iamenr0s/molecule-action@main
NOTE: Please ensure that the checkout action places the file in ${{ github.repository }} for molecule to locate your role correctly.
To test your role against multiple distributions, you can follow this pattern:"
---
name: Role-CI
on:
- push
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: "${{ github.repository }}"
- name: yamllint
uses: ibiqlik/[email protected]
with:
config_data: |
extends: default
rules:
new-line-at-end-of-file:
level: warning
trailing-spaces:
level: warning
line-length:
level: warning
test:
needs:
- yamllint
runs-on: ubuntu-latest
strategy:
matrix:
image:
- alpine
- amazonlinux
- debian
- centos
- fedora
- opensuse
- ubuntu
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: "${{ github.repository }}"
- name: molecule
uses: iamenr0s/molecule-action@main
with:
image: "${{ matrix.image }}"
options: parallel
scenario: default
This project is licensed under the MIT License.