mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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
|
7 years ago | |
|---|---|---|
| .. | ||
| host_vars | 7 years ago | |
| targets | 7 years ago | |
| cloud-config-aws.ini.template | 7 years ago | |
| cloud-config-azure.ini.template | 7 years ago | |
| cloud-config-cloudscale.ini.template | 7 years ago | |
| cloud-config-cs.ini.template | 7 years ago | |
| cloud-config-gcp.ini.template | 7 years ago | |
| cloud-config-hcloud.ini.template | 7 years ago | |
| cloud-config-opennebula.ini.template | 7 years ago | |
| cloud-config-openshift.kubeconfig.template | 8 years ago | |
| cloud-config-scaleway.ini.template | 7 years ago | |
| cloud-config-tower.ini.template | 7 years ago | |
| cloud-config-vultr.ini.template | 7 years ago | |
| integration.cfg | 7 years ago | |
| integration_config.yml | 8 years ago | |
| inventory | 7 years ago | |
| inventory.networking.template | 7 years ago | |
| inventory.remote.template | 9 years ago | |
| inventory.winrm.template | 7 years ago | |
| network-integration.cfg | 7 years ago | |
| target-prefixes.network | 7 years ago | |
| windows-integration.cfg | 7 years ago | |