Molecule seems to have changed it's ROLE_PATH

Hi folks,

So I ran into this really weird issue today, I was making a new role and for that role I wanted to make some Molecule tests (as we all do, right? :wink: )

Previously, I had this as my converge.yml:

- name: 'Converge'
  hosts: 'all'
  tasks:
    - name: 'Run my role'
      ansible.builtin.include_role:
        name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"

And up until Molecule 25.3.1 this works just fine™. But now when I run the same code it errors out with:


PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [dante]

TASK [Run role] ****************************************************************
ERROR! the role 'dante_proxy' was not found in /home/ansible/roles/dante_proxy/molecule/default/roles:/home/ansible/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/ansible/roles/dante_proxy/molecule/default

The workaround? →

---
- name: 'Converge'
  hosts: 'all'
  tasks:
  # lint does not like this....
    - name: 'Run role'  # noqa role-name[path]
      ansible.builtin.include_role:
        name: "../../../{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"

See below:


PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [dante]

TASK [Run role] ****************************************************************

TASK [../../../dante_proxy : Ensure packages] **********************************
ok: [dante]

TASK [../../../dante_proxy : Ensure configuration] *****************************
ok: [dante]

TASK [../../../dante_proxy : Ensure service] ***********************************
ok: [dante]

PLAY RECAP *********************************************************************
dante      

So I have some questions:

  • This hacky workaround is probably not what I should do, what is the correct means of setting the roles path?
  • Why did it move in the first place? It was working just fine :wink:
2 Likes

Well, it seems I wasn’t the only one surprised :slight_smile: molecule test fails in ansible role directory with molecule version 25 · Issue #4391 · ansible/molecule · GitHub

1 Like