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 00000000000..0cbd977d91c --- /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 a06a5e0f052..7970e31e1e4 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -543,6 +543,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