fix: reduce galaxy requirements check noise and de-duplicate path checks#3901
Open
ksrp1984 wants to merge 1 commit into
Open
fix: reduce galaxy requirements check noise and de-duplicate path checks#3901ksrp1984 wants to merge 1 commit into
ksrp1984 wants to merge 1 commit into
Conversation
Skip silently when roles/ or collections/ subdirectory doesn't exist. Warn when subdirectory exists but has no requirements.yml. Log a single message listing searched paths when no shared requirements.yml is found, instead of one line per checked path.
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
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.
Description
Problem
On every Ansible task run, Semaphore probes a fixed set of candidate
requirements.ymllocations and logs a line for each one that is missing:That is up to 8 lines per run, and some are exact duplicates (the shared
<dir>/requirements.ymlis probed once for roles and once for collections).When collections/roles are managed globally and no requirements files are
expected in the repo, this is pure noise that hides the meaningful task output.
Related: #2982, #3111.
Behavior change — full algorithm
Requirements resolution is reworked into a collect → check → install flow.
Candidate paths are classified into two kinds, each with its own rule.
Search locations
Two base directories are searched:
GetPlaybookDir())getRepoPath())If these two resolve to the same directory (e.g. the playbook lives at the repo
root), it is searched once — duplicate base directories are removed up front.
Kind 1 — type-specific subdirectory files
<base>/roles/requirements.yml(roles only)<base>/collections/requirements.yml(collections only)roles/(orcollections/) directory does not existrequirements.ymlis missingrequirements.ymlis presentKind 2 — shared root file
<base>/requirements.ymlThis file may contain both
roles:andcollections:sections (thecanonical Ansible layout), so when present it is installed twice — once with
ansible-galaxy role installand once withansible-galaxy collection install.requirements.ymlexists (any base dir)requirements.ymlexists in any base dirWhat gets de-duplicated vs. what is intentionally kept
duplicate base directory when playbook dir == repo root.
requirements.ymlis still processedfor both roles and collections — this is not a duplicate, the two
ansible-galaxysubcommands read different sections of the same file.Before / after (example: repo with no requirements files, playbook at repo root)
Before — 8 lines (with duplicates):
After — 1 line:
(the
roles/andcollections/subdirectories don't exist, so they are skipped silently)Implementation notes
resolveGalaxyRequirements()performs collect/check/logging and returnstwo slices of existing paths (roles, collections).
installGalaxyRequirementsFile()no longer does existence checks or"not found" logging — it is only ever called with files that exist. Its md5
change-detection ("has no changes. Skip…") is unchanged.
installRolesRequirements()/installCollectionsRequirements()are kept andreused; they now take a pre-resolved
[]stringof existing paths.InstallRequirements()signature is unchanged.Closes #2982
Closes #3111