This repository provides a base scaffolding template to use as a quick start of all Ansible roles at @Appsilon. Includes best practices that should always be used, like linter, tests, CI, etc.
- Click "Use this template" to create a new repository from it.
- Update
./meta/main.ymlwith updated repository and role names. - Update
./role_README.mdwith updated to repository and role name. - Rename
./role_README.mdtoREADME.md. - Start coding! You're free to change anything.
To execute tests locally, it is necessary to install the following dependencies:
Create a Python environment:
python3 -m venv .venvActivate the environment:
source .venv/bin/activateInstall molecule (and its dependencies) inside the environment:
python3 -m pip install -r requirements.txtmolecule testTo perform quick test after some modification:
molecule create
molecule converge
molecule verifyTo log into the running instance for troubleshooting purposes:
molecule loginAt the end of the test, destroy the environment:
molecule destroyWe want to provide high quality code. For this reason we are using several
pre-commit hooks and GitHub Actions
workflow. A pull-request to the main
branch will trigger these validations and lints automatically. Please check your
code before you will create pull-requests.
Before you can run hooks, you need to have the pre-commit
installed.
pip install pre-commit
pre-commit installIf you are going to enforce Conventional
Commits commit message style on the title
you will also need to
install gitlint.
pip install gitlintYou then need to install the pre-commit hook like so:
pre-commit install --hook-type commit-msgIt's important that you run
pre-commit install --hook-type commit-msg, even if you've already usedpre-commit installbefore.pre-commit installdoes not installcommit-msghooks by default!
To manually trigger gitlint using pre-commit for your last commit message,
use the following command:
pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSGIn case you want to change gitlint's behavior, you should either use a
.gitlint file (see
Configuration) or modify the
gitlint invocation in your .pre-commit-config.yaml file like so:
- repo: https://github.com/jorisroovers/gitlint
rev: # Fill in a tag / sha here
hooks:
- id: gitlint
args: [--contrib=CT1, --msg-filename]See pre-commit documentation and GitHub Actions documentation for further details.