# Ansible-test not loading collections from requirements.yml

**URL:** <https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431>\
**Category:** Get Help\
**Tags:** windows, ansible-test, aws\
**Created:** [January 2, 2025, 11:50pm UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431 "2025-01-02T23:50:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![branic](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/branic/32/363_2.png) [@branic](https://forum.ansible.com/u/branic)\
**Post date:** [January 2, 2025, 11:50pm UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/1 "2025-01-02T23:50:07Z")

</div>

I’m attempting to run the integration tests for the `ec2_vpc_nacl` moudule of the `amazon.aws` collection and I’m running into an issue where the `community.general` collection is not installed in the container.

The command I’m running is:

```auto
ansible-test integration ec2_vpc_nacl --docker

```

(I’ve also tried using different container images such as `fedora40`).

The integration tests always fail because one of the tasks is attempting to use the `community.general.json_query` module, but the `community.general` collection isn’t being installed in the container by `ansible-test`.

```auto
TASK [ec2_vpc_nacl : Set helpful facts about subnets] **************************
fatal: [testhost]: FAILED! => {"msg": "template error while templating string: Could not load \"community.general.json_query\": 'Invalid plugin FQCN (community.general.json_query): unable to locate collection community.general'. String: {{ subnets | community.general.json_query('results[*].subnet.id') }}. Could not load \"community.general.json_query\": 'Invalid plugin FQCN (community.general.json_query): unable to locate collection community.general'"}

```

(NOTE: To get to the above task the fix from [PR 2429](https://github.com/ansible-collections/amazon.aws/pull/2429) needs to be applied or use the `--start-at-task "Fetch AZ availability"`)

I found that the `community.general` collection wasn’t added to the `integration/tests/requirements.yml` file so I added it locally to the file:

```auto
---
collections:
  - ansible.windows
  - ansible.utils # ipv6 filter
  - amazon.cloud # used by integration tests - rds_cluster_modify
  - community.general # used by integration test - ec2_vpc_nacl

```

However, even after adding the collection to the `requirements.yml` it is not found when running the test.

What do I need to do to get the collection installed in the container to be used during testing?

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [January 3, 2025, 6:39am UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/2 "2025-01-03T06:39:10Z")

</div>

Not really an answer, but one of my personal bugbears: this should just be using standard Jinja, there’s nothing in there that requires the use of a non-standard filter.

```yaml
        subnet_ids: "{{ subnets.results | map(attribute='subnet.id') }}"
        subnet_names: "{{ subnets.results | map(attribute='subnet.tags.Name') }}"

```

There are a limited set of circumstances where `json_query` is more usable than plain Jinja, and this is not one of them.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 3, 2025, 7:54am UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/3 "2025-01-03T07:54:03Z")

</div>

> [@branic](#):
>
> What do I need to do to get the collection installed in the container to be used during testing?

You need to have it installed / checked out in the same directory structure from where you run ansible-test in amazon.aws. So if you are in `/path/to/ansible_collections/amazon/aws`, you need another directory `/path/to/ansible_collections/community/general` (with exactly the same `/path/to`) where community.general is installed (or its Git repo checked out). Only then will ansible-test find it (and automatically copy it into the Docker container).

The `integration/tests/requirements.yml` file is not used by ansible-test.

---

<div class="post-metadata">

**Author:** ![branic](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/branic/32/363_2.png) [@branic](https://forum.ansible.com/u/branic)\
**Post date:** [January 3, 2025, 3:15pm UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/4 "2025-01-03T15:15:33Z")

</div>

I have thought about changing the test to not use `json_query` as I think it would be cleaner too.

---

<div class="post-metadata">

**Author:** ![branic](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/branic/32/363_2.png) [@branic](https://forum.ansible.com/u/branic)\
**Post date:** [January 3, 2025, 3:16pm UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/5 "2025-01-03T15:16:35Z")

</div>

Thanks @felixfontein. I didn’t realize that and couldn’t find that documented anywhere.

---

<div class="post-metadata">

**Author:** ![dbrennand](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dbrennand/32/7830_2.png) [@dbrennand](https://forum.ansible.com/u/dbrennand)\
**Post date:** [September 3, 2025, 7:31pm UTC](https://forum.ansible.com/t/ansible-test-not-loading-collections-from-requirements-yml/39431/6 "2025-09-03T19:31:33Z")

</div>

Hi folks, I’ve just found this thread whilst I was raising my own issue somewhat related to this. I’m creating some unit tests for the `community.beszel` collection and slightly different to running integration tests I’m using the command: `ansible-test units --docker --requirements`

I noticed that the unit tests are failing in the container due to the `ansible_collections.community.internal_test_tools` not being found. I thought that `ansible-test` would use my `requirements.yml` file and install this collection dependency like it does with Python `requirements.txt` but that doesn’t seem to be the case based on @felixfontein’s last response.

> **[community.beszel/tests/unit at 0.3.0 · ansible-collections/community.beszel](https://github.com/ansible-collections/community.beszel/tree/0.3.0/tests/unit)**
>
> Ansible content to automate the configuration of Beszel Hub and Agents. - ansible-collections/community.beszel

To @branic point, I also couldn’t find:

> So if you are in `/path/to/ansible_collections/amazon/aws` , you need another directory `/path/to/ansible_collections/community/general` (with exactly the same `/path/to` ) where community.general is installed (or its Git repo checked out). Only then will ansible-test find it (and automatically copy it into the Docker container).

Documented anywhere either. Where could this be documented, I don’t mind raising a PR for it.
