community.general/lib/ansible/plugins
Ian Wienand 39945b8570 Make query with errors='ignore' return a blank list (#57038)
The jinja2 query() function (or lookup with wantslist=True, which is
the same thing) should always return a list.

However, if you combine a query with errors='ignore' and take the
error path, the current code returns a None value.  This is important
in a case such as

 - name: Conditional include file
   import_tasks: '{{ item }}'
   vars:
     params:
       files:
         - path/file1.yaml
         - path/file2.yaml
   loop: "{{ q('first_found', params, errors='ignore') }}"

If neither file1.yaml or file2.yaml exist, this should do nothing by
returning an empty list to the loop.  Currently if you run the above
task you'll get a rather unhelpful:

 Invalid data passed to 'loop', it requires a list, got this instead: .

This change ensures that when a query ignores an error, it returns a
empty list.  The errors='ignore' case is tested in several variants
with first_found.  The extant (but deprecated) "skip: True" for
first_found doesn't seem to be explicitly tested; a test is added here
to avoid regressions before removal in 2.12.

This fixes a regression you'll hit if you follow the suggestion in the
deprecation message included with
e17a2b502d to use errors=ignore over
"skip: True" for first_found.  This change adds an example that points
out the query/lookup difference and also fixes the error message to
not mention the now deprecated "skip: True".

Closes #56775
2019-05-29 13:23:02 -04:00
..
action Not native, but text (#55676) 2019-05-24 14:49:04 -04:00
become Keep machinectl from parsing options of cmd (#56572) 2019-05-23 16:01:40 -04:00
cache Fix inventory cache interface (#50446) 2019-03-06 12:12:35 -06:00
callback added missing version_added 2019-05-22 17:04:36 -04:00
cliconf Added the 'show commit config diff' output available from the IOSXR device (#54875) 2019-05-27 17:30:14 +05:30
connection Fixed misc typos (#57103) 2019-05-29 08:56:05 +02:00
doc_fragments Handle openstacksdk < 0.10.0: fix AttributeError (#50285) 2019-05-24 10:27:47 -05:00
filter Add seed parameter to random_mac filter (#51841) 2019-05-16 13:41:08 -04:00
httpapi eos_config: Fix test issues (#56180) 2019-05-09 18:02:24 +05:30
inventory Return results even when the cache is disabled (#55505) 2019-05-28 13:44:00 -04:00
lookup Make query with errors='ignore' return a blank list (#57038) 2019-05-29 13:23:02 -04:00
netconf Move missing library abort to use rather than import for netconf (#55384) 2019-04-23 09:19:47 -04:00
shell removed previouslly deprecated settings (#55662) 2019-05-15 16:36:30 -04:00
strategy Be sure to use the active state when checking for any_errors_fatal (#55779) 2019-04-26 10:31:30 -05:00
terminal add terminal initial prompt for initial connection (#57057) 2019-05-29 12:37:13 -04:00
test Simplify regex filter code (#50202) 2019-02-03 15:10:16 -05:00
vars Fix encoding issues with file paths. (#50830) 2019-01-14 13:06:47 -08:00
__init__.py Misc typo fixes (#53284) 2019-03-04 15:30:18 -05:00
loader.py Not native, but text (#55676) 2019-05-24 14:49:04 -04:00