summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-06-08 07:52:48 -0700
committerGitHub <noreply@github.com>2022-06-08 09:52:48 -0500
commit6291280ef8af4993f45e970ee07744f0e849083f (patch)
treeb73e85993a339a00d8e36b5478de2f23c44dfcdb
parent567a295c0026d6e79b8970846ee3550b4c124982 (diff)
downloadansible-6291280ef8af4993f45e970ee07744f0e849083f.tar.gz
[stable-2.13] Make fuzzy plugin matching deterministic. (#77997)
(cherry picked from commit 5a0b230e240664ea4b316fe1592ce84003c9946c) Co-authored-by: Matt Clay <matt@mystile.com>
-rw-r--r--changelogs/fragments/plugin-loader-deterministic-fuzzy-match.yml2
-rw-r--r--lib/ansible/plugins/loader.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/changelogs/fragments/plugin-loader-deterministic-fuzzy-match.yml b/changelogs/fragments/plugin-loader-deterministic-fuzzy-match.yml
new file mode 100644
index 0000000000..0cbd977d91
--- /dev/null
+++ b/changelogs/fragments/plugin-loader-deterministic-fuzzy-match.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - plugin loader - Sort results when fuzzy matching plugin names (https://github.com/ansible/ansible/issues/77966).
diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py
index 019a5bcf24..dfb6242300 100644
--- a/lib/ansible/plugins/loader.py
+++ b/lib/ansible/plugins/loader.py
@@ -533,6 +533,8 @@ class PluginLoader:
if not found_files:
return plugin_load_context.nope('failed fuzzy extension match for {0} in {1}'.format(full_name, acr.collection))
+ found_files = sorted(found_files) # sort to ensure deterministic results, with the shortest match first
+
if len(found_files) > 1:
# TODO: warn?
pass