Browse Source

ensure csv info is empty before attempting to extract, adjust query for pkg_mft struct change

Grega Bremec 7 months ago
parent
commit
e27ffc2275
1 changed files with 8 additions and 3 deletions
  1. 8 3
      playbooks/roles/deploy-operator/tasks/main.yml

+ 8 - 3
playbooks/roles/deploy-operator/tasks/main.yml

@@ -32,6 +32,11 @@
     - all_csv.resources is defined
     - (all_csv.resources | length) > 0
 
+- name: Reset CSV data
+  set_fact:
+    csv_ns: ''
+    csv_name: ''
+
 - name: Get details about the CSV if found
   set_fact:
     csv_ns: "{{ found_csv[0] | community.general.json_query('metadata.namespace') }}"
@@ -43,8 +48,8 @@
 - debug:
     msg: Operator {{ op.op_pkg }} is already installed in {{ csv_ns }} as {{ csv_name }} (desired_csv == {{ op.desired_csv }}).
   when:
-    - csv_ns is defined
-    - csv_name is defined
+    - csv_ns != ''
+    - csv_name != ''
 
 - name: Only proceed here if the CSV was not found anywhere yet
   block:
@@ -73,7 +78,7 @@
 
     - name: Search for any channels that provide desired_csv
       set_fact:
-        found_chn: '{{ (pkg_mft | community.general.json_query("resources[0].status.channels[?currentCSV == `" + op.desired_csv + "`].name")) }}'
+        found_chn: '{{ (pkg_mft | community.general.json_query("status.channels[?currentCSV == `" + op.desired_csv + "`].name")) }}'
       when:
         - pkg_mft is defined
         - pkg_mft.resources | length > 0