1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration
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
..
host_vars ansible-test: Use psrp for 2008 host ci_complete (#55273) 2019-04-23 08:13:03 +10:00
targets Make query with errors='ignore' return a blank list (#57038) 2019-05-29 13:23:02 -04:00
cloud-config-aws.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-azure.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-cloudscale.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-cs.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-gcp.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-hcloud.ini.template Add Hetzner Cloud to CI integration tests. 2019-04-09 15:41:50 -07:00
cloud-config-opennebula.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-openshift.kubeconfig.template Initial OpenShift integration test support. (#36207) 2018-02-14 13:39:42 -08:00
cloud-config-scaleway.ini.template Migrate Scaleway tests to integration tests 2019-04-09 15:41:30 -07:00
cloud-config-tower.ini.template Overhaul ansible-test cloud test plugins. (#53044) 2019-02-28 18:25:49 -08:00
cloud-config-vultr.ini.template tests: vultr: convert legacy tests to targets (#50156) 2019-01-07 22:23:54 +01:00
integration.cfg Force tests to set ansible_python_interpreter. (#54191) 2019-03-21 21:54:41 -07:00
integration_config.yml Fix pip integration test. 2018-01-31 23:26:16 -08:00
inventory Overhaul ansible-test code coverage and injector. (#53510) 2019-03-13 07:14:12 -07:00
inventory.networking.template Rename MSC modules to MSO nomenclature (#50959) 2019-01-16 14:53:38 +01:00
inventory.remote.template
inventory.winrm.template Cleanup integration test inventory. (#50753) 2019-01-10 14:45:12 -08:00
network-integration.cfg Use stdout_callback yaml for network-integration tests (#56102) 2019-05-06 21:01:40 +05:30
target-prefixes.network Rename MSC modules to MSO nomenclature (#50959) 2019-01-16 14:53:38 +01:00
windows-integration.cfg Enable force_handlers for integration tests. 2019-01-25 08:51:57 -08:00