diff --git a/roles/common/tasks/cr_tests.yml b/roles/common/tasks/cr_tests.yml index fcb646d7..7ee15920 100644 --- a/roles/common/tasks/cr_tests.yml +++ b/roles/common/tasks/cr_tests.yml @@ -1,4 +1,7 @@ -- name: Verify that a CR exists {{ common_cr_test_id }} +--- +- name: | + Verify that the {{ item.kind }} {{ item.name }} CR exists + {{ common_cr_test_id }} ansible.builtin.command: cmd: | oc get {{ item.kind }} {{ item.name }} @@ -7,14 +10,21 @@ failed_when: - result.rc != 0 -- name: Verify that a CR is ready {{ common_cr_ready_test_id }} + # This is added so that the task name will be rendered correctly + # If item.condition_type is used and it doesn't exist, then the + # literal template text will appear as the task name + # e.g. "Verify that the {{ item.kind }} {{ item.name }} CR is {{ item.condition_type }}" +- name: Set the condition type + ansible.builtin.set_fact: + condition_type: "{{ item.condition_type if item.condition_type is defined else '' }}" + +- name: | + Verify that the {{ item.kind }} {{ item.name }} CR is {{ condition_type }} + {{ common_cr_ready_test_id if condition_type | length > 0 }} ansible.builtin.command: cmd: | - oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ item.condition_type }}")].status}{"\n"}' + oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ condition_type }}")].status}{"\n"}' register: result changed_when: false failed_when: - result.stdout != "True" - when: - - common_cr_ready_test_id is defined - - item.condition_type is defined