I am trying to understand how to configure Ansible linting as part of my testing phase but unfortunately all information and documentation out there about molecule seems to be outdated.
First, this is the molecule version I am running:
molecule --version molecule 6.0.2 using python 3.12
ansible:2.16.0
azure:23.5.0 from molecule_plugins
containers:23.5.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:6.0.2 from molecule
docker:23.5.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
ec2:23.5.0 from molecule_plugins
gce:23.5.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.5.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0 vagrant:23.5.0 from molecule_plugins
And this is my molecule.yml
file.
---
dependency:
name: galaxy
options:
requirements-file: requirements.yml
platforms:
- name: molecule-debian
image: debian:12
driver:
options:
managed: False
login_cmd_template: "podman exec -ti {instance} bash"
ansible_connection_options:
ansible_connection: podman
provisioner:
name: ansible
lint:
name: ansible-lint
enabled: True
lint: ansible-lint
verifier:
name: ansible
When running molecule test
all steps are running as expected, however I don't see any errors coming from the linter.
Also, it seems the molecule lint
command has been removed. There is a syntax
step in the default scenario, but I was unable to figure our how to use it. Again, docs are not helping.
What's the proper way to manage the linting phase as part of the Ansible code testing with Molecule?
% molecule matrix test
INFO Test matrix
---
default:
- dependency
- cleanup
- destroy
- syntax
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
% molecule lint
Usage: molecule [OPTIONS] COMMAND [ARGS]...
Try 'molecule --help' for help.
Error: No such command 'lint'.
After further investigation, this is of course on purpose. New way is to run the linters separately.
https://github.com/ansible/molecule/discussions/3914