Skip to content

Idempotence test fail in handler not attributed to handler #4414

@Perdu

Description

@Perdu

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • The issue is not specific to any driver other than 'default' one

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions