Avoid to use 'length' filter with null value

This error occurs when variables are null and
DEFAULT_JINJA2_NATIVE is enabled:

    object of type 'NoneType' has no len()

Change-Id: I7c69be60b846c03e30a0a6e8893bf2f3a3d5e5b8
This commit is contained in:
Pierre-Louis Bonicoli 2020-07-22 01:18:30 +02:00
parent 1242a98137
commit 222056a26f
No known key found for this signature in database
GPG Key ID: 06914C4A5EDAA6DD
2 changed files with 5 additions and 5 deletions

View File

@ -23,4 +23,4 @@
package:
name: "{{ tox_molecule_packages }}"
when:
- (tox_molecule_packages | length) > 0
- tox_molecule_packages | default(false)

View File

@ -24,7 +24,7 @@
being gathered prior to executing this role.
when:
- not (docker_distro_vars_loaded | bool)
- (docker_distro_packages | length) < 1
- not docker_distro_packages
- name: Sanity check for distro install
fail:
@ -34,7 +34,7 @@
required. Please check your settings.
docker_distro_packages = {{ docker_distro_packages }}
when:
- (docker_distro_packages | length) < 1
- not docker_distro_packages
- not (use_upstream_docker | bool)
- name: Sanity check for upstream install
@ -45,7 +45,7 @@
required. Please check your settings.
docker_upstream_distro_packages = {{ docker_upstream_distro_packages }}
when:
- (docker_upstream_distro_packages | length) < 1
- not docker_upstream_distro_packages
- use_upstream_docker | bool
- name: Sanity check for upstream install mirrors
@ -54,7 +54,7 @@
The variable `docker_mirror_base_url` is null, and upstream installation has been enabled.
Check your settings.
when:
- (docker_mirror_base_url | length) < 1
- not docker_mirror_base_url
- use_upstream_docker | bool
- include_tasks: "docker-{{ (use_upstream_docker | bool) | ternary('upstream', 'distro') }}.yaml"