community.general/lib/ansible/plugins/lookup
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
..
__init__.py
_openshift.py
_redis_kv.py
aws_account_attribute.py fix AWS plugin credential precedence for environment variables (#52945) 2019-03-25 16:53:11 -04:00
aws_secret.py Update aws_secret.py (#53390) 2019-03-06 13:31:55 -05:00
aws_service_ip_ranges.py
aws_ssm.py Fix syntax highlighting (#53945) 2019-03-21 17:08:23 +00:00
cartesian.py
chef_databag.py
config.py
conjur_variable.py
consul_kv.py lookup: consul_kv: Add datacenter parameter (#56647) 2019-05-22 08:02:39 +02:00
cpm_metering.py
cpm_status.py
credstash.py Fix exception handling in credtash lookup (#51099) 2019-02-18 18:28:35 -05:00
csvfile.py
cyberarkpassword.py
dict.py
dig.py
dnstxt.py
env.py
etcd.py
file.py
fileglob.py Clarify example for fileglob lookup plugin (#54941) 2019-04-07 16:24:48 +01:00
filetree.py Update documentation of filetree to mention limits of 'src' attribute (#54347) 2019-04-11 16:39:56 -05:00
first_found.py Make query with errors='ignore' return a blank list (#57038) 2019-05-29 13:23:02 -04:00
flattened.py
grafana_dashboard.py
hashi_vault.py standardize TLS connection properties (#54315) 2019-03-28 00:19:28 -05:00
hiera.py
indexed_items.py
ini.py Update ini.py (#50171) 2018-12-20 10:07:05 -05:00
inventory_hostnames.py preserve same order as inventory manager when using host lookup (#55331) 2019-04-18 15:54:03 -04:00
items.py
k8s.py standardize TLS connection properties (#54315) 2019-03-28 00:19:28 -05:00
keyring.py
laps_password.py standardize TLS connection properties (#54315) 2019-03-28 00:19:28 -05:00
lastpass.py Fix lastpass lookup error 2019-01-03 23:56:41 -08:00
lines.py
list.py
manifold.py New lookup module: manifold (#50435) 2019-03-27 07:20:15 -04:00
mongodb.py
nested.py
nios.py
nios_next_ip.py
nios_next_network.py
onepassword.py Onepassword document fixes (#51527) 2019-01-31 09:48:55 -05:00
onepassword_raw.py Onepassword document fixes (#51527) 2019-01-31 09:48:55 -05:00
password.py
passwordstore.py passwordstore: add hint for subkey=password (#54221) 2019-04-05 15:11:14 -05:00
pipe.py
rabbitmq.py
random_choice.py
redis.py lookup: redis: fix plugin returning repr'd byte objects (#52854) 2019-02-27 12:04:18 +01:00
sequence.py Clarify return value of the sequence lookup (#53275) 2019-03-04 14:09:55 -05:00
shelvefile.py
skydive.py PR to start support for Skydive integration with Ansible (#50857) 2019-02-19 16:18:40 +05:30
subelements.py
template.py Templar: encapsulate _available_variables (#55435) 2019-05-20 11:49:54 -04:00
together.py
url.py
varnames.py varnames lookup (#51621) 2019-02-26 13:59:24 -05:00
vars.py Templar: encapsulate _available_variables (#55435) 2019-05-20 11:49:54 -04:00