From a9407a4803bcae4bcd21828c2250b148d9532c48 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Thu, 30 Apr 2020 11:34:58 -0600 Subject: [PATCH] use selectattr instead of json_query Some tests were getting the following error: ``` Unexpected templating type error occurred on ({{ network_connections | json_query('[*][ieee802_1x]') | flatten | count > 0 }}): 'NoneType' object is not iterable" ``` In general it is better to avoid the use of `json_query` and use the older built-in jinaj2 filters such as `selectattr`, unless you need to perform a complex query of complex json data. In this case, not sure what the problem was with the input json, but using `selectattr` seems to have fixed it. --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6b15964..d3977cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -22,7 +22,7 @@ network_provider: "{{ network_provider_current }}" # wpa_supplicant is required if any ieee802_1x connections are defined wpa_supplicant_required: "{{ network_connections | - json_query('[*][ieee802_1x]') | flatten | count > 0 }}" + selectattr('ieee802_1x', 'defined') | list | count > 0 }}" _network_packages_default_802_1x: ["{% if wpa_supplicant_required %}wpa_supplicant{% endif %}"]