From 5a0b230e240664ea4b316fe1592ce84003c9946c Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 6 Jun 2022 21:22:41 -0700 Subject: [PATCH] Make fuzzy plugin matching deterministic. --- .../fragments/plugin-loader-deterministic-fuzzy-match.yml | 2 ++ lib/ansible/plugins/loader.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/plugin-loader-deterministic-fuzzy-match.yml 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