# Molecule: how to include local roles PATH to test playbook

**URL:** <https://forum.ansible.com/t/molecule-how-to-include-local-roles-path-to-test-playbook/10547>\
**Category:** Get Help\
**Tags:** role, playbook, molecule\
**Created:** [October 28, 2024, 5:18pm UTC](https://forum.ansible.com/t/molecule-how-to-include-local-roles-path-to-test-playbook/10547 "2024-10-28T17:18:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daks](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/daks/32/5277_2.png) [@daks](https://forum.ansible.com/u/daks)\
**Post date:** [October 28, 2024, 5:18pm UTC](https://forum.ansible.com/t/molecule-how-to-include-local-roles-path-to-test-playbook/10547/1 "2024-10-28T17:18:37Z")

</div>

Hello,

I want to test a whole setup to provision my servers. It includes playbooks, tasks and also roles I have created and stored locally in a `roles/` directory.

In my `ansible.cfg` I added

```auto
roles_path=./roles

```

and `ansible-playbook` find it and execute it

In Molecule, I can’t find the syntax to make it find it so it throw an error about “the role ‘apt’ was not found”

In `molecule/default/molecule.yml` I tested creating an `env` parameter with no success

```auto
verifier:
  name: ansible
  env:
    # none works
    ANSIBLE_ROLES_PATH: /tmp/ansible.debug/roles/
    ANSIBLE_ROLES_PATH: ../../roles/ 
    ROLES_PATH: /tmp/ansible.debug/roles/

```

I also tested with the following syntax

```auto
verifier:
  name: ansible
  config_options:
    defaults:
      roles_path: ../../roles

```

but got this error

```auto
["Additional properties are not allowed ('config_options' was unexpected)"]

```

Any idea of how it can be done?

**EDIT**

```auto
molecule --version
molecule 24.9.0 using python 3.12 
    ansible:2.17.5
    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
    default:24.9.0 from molecule
    docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    ec2: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
    openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.3 from molecule_plugins

```

---

<div class="post-metadata">

**Author:** ![daks](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/daks/32/5277_2.png) [@daks](https://forum.ansible.com/u/daks)\
**Post date:** [October 28, 2024, 5:51pm UTC](https://forum.ansible.com/t/molecule-how-to-include-local-roles-path-to-test-playbook/10547/2 "2024-10-28T17:51:50Z")

</div>

putting the `env` config in the `provisioner` part not in the `verifier` one seems to be a better idea! 🙂 … and it’s logical

The working config is then

```auto
provisioner:
  name: ansible
  options:
    vvv: true
  env:
    ANSIBLE_ROLES_PATH: ../../roles/

```

_reading [molecule/src/molecule/provisioner/ansible.py at main · ansible/molecule · GitHub](https://github.com/ansible/molecule/blob/main/src/molecule/provisioner/ansible.py#L233) it should also be possible to use the `config_options` solution so not sure why it doesn’t like it_

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 27, 2024, 5:52pm UTC](https://forum.ansible.com/t/molecule-how-to-include-local-roles-path-to-test-playbook/10547/3 "2024-11-27T17:52:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
