linux-system-roles / network

An ansible role to configure networking
https://linux-system-roles.github.io/network/
BSD 3-Clause "New" or "Revised" License
237 stars 106 forks source link

don't compare booleans, this was fixed only very recently: https://github.com/pallets/jinja/issues/813 #245

Open tyll opened 4 years ago

tyll commented 4 years ago

don't compare booleans, this was fixed only very recently: https://github.com/pallets/jinja/issues/813

Originally posted by @pcahyna in https://github.com/linux-system-roles/network/pull/232/files

tyll commented 4 years ago

Possible patch:

diff --git a/tests/tasks/test_802.1x_capath.yml b/tests/tasks/test_802.1x_capath.yml
index f98b1b2..b8d7949 100644
--- a/tests/tasks/test_802.1x_capath.yml
+++ b/tests/tasks/test_802.1x_capath.yml
@@ -79,13 +79,15 @@
         - __NM_capath_ignored_NVRs

     - name: Assert role behavior
+      vars:
+        expected_failure: __network_NM_NVR.stdout in __NM_capath_ignored_NVRs
+        failure: __network_connections_result.failed
       assert:
-        that: __network_connections_result.failed ==
-          (__network_NM_NVR.stdout in __NM_capath_ignored_NVRs)
-        msg: "Role {{ __network_connections_result.failed and 'failed'
-            or 'did not fail' }} but was expected
-            {{ (__network_NM_NVR.stdout in __NM_capath_ignored_NVRs)
-            and '' or 'not' }} to fail. NM NVR: {{ __network_NM_NVR.stdout }}"
+        that: (failure and expected_failure) or
+          (not failure and not expected_failure)
+        msg: "Role {{ failure and 'failed' or 'did not fail' }} but was expected
+          {{ expected_failure and '' or 'not' }} to fail.
+          NM NVR: {{ __network_NM_NVR.stdout }}"

     - name: Assert ping succeeded
       assert:
tyll commented 4 years ago

@pcahyna are the Jinja2 requirements for the system roles documented anywhere? Please provide a URL if they are.

pcahyna commented 4 years ago

@tyll here: https://github.com/linux-system-roles/storage/issues/49

pcahyna commented 4 years ago

@tyll more formally here: https://github.com/oasis-roles/meta_standards#ansible-best-practices