first_found fix no terms option (#76550) (#81451)

For backport without the fix for multiple items clobbering previous settings

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
pull/81632/head
Klaus Frank 1 year ago committed by GitHub
parent caf8cdbe91
commit ac8188febd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- first found lookup has been updated to use the normalized argument parsing (pythonic) matching the documented examples.

@ -165,6 +165,9 @@ class LookupModule(LookupBase):
total_search = []
skip = False
if not terms and kwargs:
terms = ['']
# can use a dict instead of list item to pass inline config
for term in terms:
if isinstance(term, Mapping):

@ -94,3 +94,11 @@
- assert:
that:
- foo is defined
# TODO: no 'terms' test
- name: test first_found lookup with no terms
set_fact:
no_terms: "{{ query('first_found', files=['missing1', 'hosts', 'missing2'], paths=['/etc'], errors='ignore') }}"
- assert:
that: "no_terms|first == '/etc/hosts'"

Loading…
Cancel
Save