A template for using molecule to develop ansible roles. To be an example, this role installs itself.
- GitHub Actions workflow for testing and releasing to ansible galaxy
- pre-commit configuration for linting project files
- ansible: ansible-lint linting, yamlfix formatting
- jinja: jinjalint linting
- markdown: pymarkdown linting
- python: flake8 linting, black formatting
- molecule-qemu configured for testing with x86_64 and aarch64 platforms. This example uses my fork with added features. See these for configuring the VMs for molecule.
- pytest-testinfra for testing state with python.
- python3
- qemu-system-x86_64, qemu-system-aarch64, mkisofs, qemu-img for running molecule instances, see molecule-qemu for details. Additionally see workflow for setting up for ubuntu 22.04.
Replace my_role
with your desired role name and my_username
with your GitHub username.
-
Retrieve this repository(or fork it)
curl -LO https://github.com/glacion/molecule_template/archive/refs/heads/main.tar.gz tar -xvf main.tar.gz --strip-components=1 --one-top-level=my_role
-
Initialize git, python, and pre-commit
git init python3 -m venv .venv source .venv/bin/activate pip install . pre-commit install
-
Make necessary metadata changes
-
Run a full cycle of molecule
molecule test
-
Create a repository on GitHub
-
Retrieve your API key from galaxy
-
Save this API key as a Repository secret in your repository under the name of
GALAXY_API_KEY
settings -
Push your repository
git add . git commit -m 'initial commit' git tag 0.0.0 git remote add origin [email protected]/my_username/my_role git push -u origin main --tags
If everything is set up correctly, GitHub Actions will run tests and publish your role to galaxy.
In order to release a new version, create a new tag like git tag 0.1.0
and push with git push --tags
.
This will additionally create a new release in GitHub with the changes from the previous tag,
consider using conventional commits for a better changelog.
BSD
Can Güvendiren [email protected]