When wanting to work on a collection for ansible it is (for now1) important to check it out in a very specific folder structure or it will not be possible to run the tests for it.

When trying to run ansible-test integration it will otherwise throw the following error:

1ERROR: The current working directory must be at or below:
2
3 - an Ansible collection: {...}/ansible_collections/{namespace}/{collection}/
4
5Current working directory: <some_other_dir>

The collection must be really placed inside a subfolder of a folder called ansible_collections and neither namespace nor collection can contain any symbols except alphanumberics or underscores ([a-zA-Z0-9_]):

1ansible_collections
2└── namespace
3    └── collection

So if you want to work on an upstream collection (e.g. community.general) you should create an intermediate folder community and clone the collection into the general folder (contrary to the default checkout which would be community.general):

1ansible_collections
2└── community
3    └── general

Inside general you can now use run ansible-test integration to run the integration tests successfully:

1cd ansible_collections/community/general
2poetry init --name community.general --dependency=ansible --dependency=pyyaml --dependency=jinja2 -n
3poetry install
4poetry run ansible-test integration

  1. This might hopefully become easier in the future: https://github.com/ansible/ansible/issues/60215 ↩︎