# Using Ansible Collections in molecule test

**URL:** <https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372>\
**Category:** Ansible Project\
**Tags:** ansible-lint, galaxy-ng, kubernetes\
**Created:** [July 11, 2020, 3:20am UTC](https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372 "2020-07-11T03:20:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamesh\_Sampath1](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@Kamesh\_Sampath1](https://forum.ansible.com/u/Kamesh_Sampath1)\
**Post date:** [July 11, 2020, 3:20am UTC](https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372/1 "2020-07-11T03:20:47Z")

</div>

I am trying to use Ansible collections with my molecule test

molecule.yml

```auto

---
dependency:
name: galaxy
options:
requirements-file: molecule/common/requirements.yml
driver:
name: delegated
options:
managed: False
ansible_connection_options:
ansible_connection: local
lint: |
set -e
yamllint .
platforms:
- name: molecule-kind-ingress
provisioner:
name: ansible
verifier:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

```

With my converge.yml

```auto

---
- name: Converge
hosts: localhost
connection: local

collections:
- community.kubernetes

vars:
ansible_python_interpreter: '{{ ansible_playbook_python }}'
cluster_name: molecule-ingress
kind_home_dir: "/tmp/kind_test"
deploy_ingress: True

roles:
- role: kameshsampath.kind

```

When running the test molecule is not picking up my collection, eventually resulting in a playbook error like:

```auto

fatal: [localhost]: FAILED! => {
"reason": "couldn't resolve module/action 'helm_repository'. This often indicates a misspelling, missing collection, or incorrect module path.\n\nThe error appears to be in '/Users/kameshs/git/kameshsampath/kameshsampath.kind/tasks/ingress.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Add stable chart Repo\n ^ here\n"
}

```

my requirements.yml does have the following entry

```auto

---
collections:
- community.kubernetes

```

I am not sure if I am missing anything here ?

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [July 11, 2020, 3:34am UTC](https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372/2 "2020-07-11T03:34:40Z")

</div>

Hi,

Could you please provide `ansible-galaxy collection list` output? helm\_repository is added in Kubernetes collection 0.11.0. If your version Kubernetes collection is less than this then you need to update.

---

<div class="post-metadata">

**Author:** ![kameshs](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@kameshs](https://forum.ansible.com/u/kameshs)\
**Post date:** [July 11, 2020, 6:16am UTC](https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372/3 "2020-07-11T06:16:23Z")

</div>

I don’t see a `ansible-galaxy collection list ` command but this is what I see with debug at start of `molecule test`

```auto
ANSIBLE_COLLECTIONS_PATHS=/Users/kameshs/.cache/molecule/kameshsampath.kind/deploy_ingress/collections: ...

```

and during dependency step of the scenario I see the output like

```auto
...

Reading requirement file at '/Users/kameshs/git/kameshsampath/kameshsampath.kind/molecule/common/requirements.yml'
Process install dependency map
Opened /Users/kameshs/.ansible/galaxy_token
Processing requirement collection 'community.kubernetes'
Collection 'community.kubernetes' obtained from server default https://galaxy.ansible.com/api/
Starting collection install process
Installing 'community.kubernetes:0.11.1' to '/Users/kameshs/.cache/molecule/kameshsampath.kind/deploy_ingress/collections/ansible_collections/community/kubernetes'
Downloading https://galaxy.ansible.com/download/community-kubernetes-0.11.1.tar.gz to /Users/kameshs/.ansible/tmp/ansible-local-7917k7r02p09/tmph3nh7p5h
/

....

```

---

<div class="post-metadata">

**Author:** ![kameshs](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@kameshs](https://forum.ansible.com/u/kameshs)\
**Post date:** [July 11, 2020, 6:37am UTC](https://forum.ansible.com/t/using-ansible-collections-in-molecule-test/33372/4 "2020-07-11T06:37:52Z")

</div>

I tried using the fully qualified name like `community.kubernetes.helm_repository`, then it does pick it up. I don’t understand why that way inspite of me adding `collections: ["community.kubernetes"]` as part of the playbook
