Bundled Collection Not Found After Overriding ANSIBLE_COLLECTIONS_PATH
Introduction
This article covers a case where a job or inventory source in Ascender fails to find a collection that ships with the execution environment, because a custom ANSIBLE_COLLECTIONS_PATH value replaced the default collection paths instead of adding to them.
Problem
Setting ANSIBLE_COLLECTIONS_PATH to a single project-relative path, for example /opt/ansible/collections, replaces the entire collections search path rather than extending it. Ansible then looks for collections only in that one directory. Collections bundled with the execution environment are no longer on the path, so their modules, plugins, and inventory plugins cannot be resolved even though they are present in the image.
Symptoms
A task fails with a "couldn't resolve module/action" error, or an inventory source fails with an "unknown plugin" error, for a collection you know is installed in the execution environment.
The ansible-inventory or ansible-config diagnostic output shows a collection location that includes only your custom path, for example:
ansible collection location = /runner/project/collections
Resolution
Append the default collection paths to your custom value rather than replacing them. Under Settings > Jobs Settings > Extra Environment Variables, set:
{
"ANSIBLE_COLLECTIONS_PATH": "/opt/ansible/collections:/runner/.ansible/collections:/usr/share/ansible/collections"
}
The first entry keeps your own collections directory, and the two default entries restore access to the collections bundled with the execution environment. After saving, re-run the job or inventory sync and the collection resolves correctly.
Notes
ANSIBLE_COLLECTIONS_PATH is a full replacement, not an addition. Any time you set it, include every path Ansible needs to search, not only your own. The same rule applies to ANSIBLE_ROLES_PATH and similar path variables.
References & related articles
Building a Custom Execution Environment for Ascender
Update the Ascender Execution Environment on Kubernetes
Ascender Execution Environments
Ascender Execution Environment Setup Reference
Ansible collections search path