-
Notifications
You must be signed in to change notification settings - Fork 700
Fix first-run collection discovery by enabling plugin loader after prepare_environment #4722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cidrblock
merged 11 commits into
ansible:main
from
cidrblock:fix/enable-plugin-loader-after-prepare
Aug 14, 2025
Merged
Fix first-run collection discovery by enabling plugin loader after prepare_environment #4722
cidrblock
merged 11 commits into
ansible:main
from
cidrblock:fix/enable-plugin-loader-after-prepare
Aug 14, 2025
+191
−130
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alisonlhart
approved these changes
Aug 13, 2025
Fixes first-run collection discovery issue by calling enable_plugin_loader() after prepare_environment() has installed collections from requirements.yml and galaxy.yml files. This ensures that Ansible's plugin loader is initialized with complete collection paths, allowing Templar and other components to properly discover plugins from newly installed collections on the first run. Related to: ansible/ansible-compat#516
7733b07
to
0d91411
Compare
The SPDX license list has been updated with new license identifiers. This commit includes the automatically generated updates to maintain compatibility with the latest SPDX license database.
a40073f
to
3035649
Compare
c9eb031
to
30ea0a9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on: ansible/ansible-compat#516
Problem
When
ansible-lint
runs on collections for the first time, it fails to discover plugins from collections installed byansible-compat
duringprepare_environment()
. This manifests as "No test named 'ansible.utils.unspecified'" errors and other plugin discovery failures that work correctly on subsequent runs.Root Cause
The issue occurs because Ansible's plugin loader is initialized too early with incomplete collection paths, before
prepare_environment()
has a chance to install dependencies fromrequirements.yml
andgalaxy.yml
files.This particularly affects
Templar
usage since it internally relies on Ansible's collection loader for template rendering and plugin discovery. When the plugin loader captures incomplete collection paths early,Templar
fails to find collections that were installed duringprepare_environment()
.Solution
This PR adds a call to
app.runtime.enable_plugin_loader()
afterprepare_environment()
completes inget_app()
. This ensures that:Templar
and other components can discover plugins from newly installed collections on the first runChanges Made
app.runtime.enable_plugin_loader()
call afterprepare_environment()
Dependencies
This change requires the corresponding plugin loader gating mechanism implemented in ansible-compat PR #516, which provides:
Runtime.enable_plugin_loader()
method for explicit initializationImpact
Testing
Tested with collections that have
requirements.yml
andgalaxy.yml
dependencies. The plugin discovery now works correctly on the first run instead of requiring a second execution.