From 2b7ed0fdd266c4ce7bef8055e63cad64c0d44d40 Mon Sep 17 00:00:00 2001 From: HS-157 Date: Fri, 1 Nov 2024 10:50:46 +0100 Subject: [PATCH] Fix path object convertion to string For Windows path, there is a difference between `str(p)` & `p.as_posix()` --- ...83600-fileglob-lookup_Pattern-matching-on-directory-file.yml | 2 ++ lib/ansible/plugins/lookup/fileglob.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/83600-fileglob-lookup_Pattern-matching-on-directory-file.yml diff --git a/changelogs/fragments/83600-fileglob-lookup_Pattern-matching-on-directory-file.yml b/changelogs/fragments/83600-fileglob-lookup_Pattern-matching-on-directory-file.yml new file mode 100644 index 00000000000..d5b5eda96ae --- /dev/null +++ b/changelogs/fragments/83600-fileglob-lookup_Pattern-matching-on-directory-file.yml @@ -0,0 +1,2 @@ +minor_changes: + - fileglob lookup - Pattern matching on directory & file (https://github.com/ansible/ansible/pull/83600) diff --git a/lib/ansible/plugins/lookup/fileglob.py b/lib/ansible/plugins/lookup/fileglob.py index fa8e96359fc..02e3614fb1d 100644 --- a/lib/ansible/plugins/lookup/fileglob.py +++ b/lib/ansible/plugins/lookup/fileglob.py @@ -91,7 +91,7 @@ class LookupModule(LookupBase): for term in terms: for path in found_paths: term_results = [ - to_text(g.as_posix(), errors="surrogate_or_strict") + to_text(str(g), errors="surrogate_or_strict") for g in path.glob(term) if g.is_file() ]