This is the template I am using when writing new playbooks.
- Docker (there is no reason podman couldn't work but it is not what I personally use)
- An AMD64 or ARM64 architecture, if running inside of the included dev container.
If you are not running in a dev container, the following utilities are used alongside the ansible suite itself:
- Docker or Podman to utilize containerization in testing with
molecule
- SOPS for encrypting sensitive information, using age for encryption
- Gitleaks so sensitive data gets caught before commit
- Hadolint for
Dockerfile
linting - yq for YAML parsing wherever necessary. Note that there appear to be two popular
yq
libraries out there, but this is the one I am using. - Optional: Just for convenient command-line running.
There is no reason why you can't run it standalone in your own development environment, but for convenience I am utilizing a Visual Studio Code Development Container environment, which encapsulates all of the utilities required to operate, including the VS Code plugins that aid in development.
The Dockerfile
to create the dev environment uses specific versions of as many libraries as possible. The benefit is that something shouldn't magically break when you have built the exact same container for the 143rd time. The downside is that with enough lack of maintenance things can fall out of rev. I use apt-cache policy <package>
every so often just to ensure everything is reasonably up to date.
I also use the Just command runner for convenience. You can see all eligible commands with just --list
. By convention, my naming scheme is as follows:
deploy
- Primary playbook execution of every eligible hostdeploy-password
- Primary playbook execution but password is required forsudo
operationsdeploy-<host>
- Primary playbook execution of the given hostlint
- Perform all linting operationstest
- Perform all testing operations
The following linters are used:
- hadolint for Dockerfile linting
- yamllint for YAML linting
- ansible-lint for Ansible-specific checks in YAML files
I am using molecule for testing roles and/or playbooks. Wherever possible, it utilizes containerization, but in cases where that is not reasonable, Vagrant and Virtualbox are used to spin up full VMs. In those cases where Vagrant/Virtualbox are used, testing support is only available for amd64 architectures.
- The numerous anonymous people who ask and answer questions on StackOverflow
- OpenAI and CoPilot for changing the way I learn and develop
- Fellow St. Louisan Jeff Geerling for his relentless devotion to Ansible, and his maintenance of numerous container images that make
molecule
testing possible withsystemd