Prerequisites
Environment
$ molecule --version
molecule 25.3.1 using python 3.13
ansible:2.18.3
azure:23.5.3 from molecule_plugins
containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
ec2:23.5.3 from molecule_plugins
openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
vagrant:23.5.3 from molecule_plugins
gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
default:25.3.1 from molecule
OS: Arch Linux
What happened
When a handler is not idempotent, molecule reports that the tasks failing the idempotence test is the task notifying the handler instead of the handler itself.
Example:
test.yml:
---
- name: 'Test task'
command:
cmd: echo "ok"
notify: "some handler"
converge.yml
---
- name: Converge
hosts: localhost
gather_facts: false
tasks:
- name: Replace this task with one that validates your content
import_tasks: '../../test.yml'
handlers:
- name: "some handler"
command:
cmd: echo "handler"
molecule test:
INFO Running default > idempotence
PLAY [Converge] ****************************************************************
TASK [Test task] ***************************************************************
changed: [localhost]
RUNNING HANDLER [some handler] *************************************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=2 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
CRITICAL Idempotence test failed because of the following tasks:
- => Test task
- => Test task
-> "Test task" is reported twice, instead of "Test task" once and "some handler" once.
Reproducing example
Prerequisites
pip checkdoes not report any conflictsEnvironment
OS: Arch Linux
What happened
When a handler is not idempotent, molecule reports that the tasks failing the idempotence test is the task notifying the handler instead of the handler itself.
Example:
test.yml:converge.ymlmolecule test:-> "Test task" is reported twice, instead of "Test task" once and "some handler" once.
Reproducing example