From eecaec2919392a8b5595927100a56d446b997d2a Mon Sep 17 00:00:00 2001 From: Eugene Marchanka <81696153+eugene-marchanka@users.noreply.github.com> Date: Sun, 9 Apr 2023 22:13:15 -0700 Subject: [PATCH] [vSphere-csi-driver] Custom namespace fails playbook (#9946) * Fix: vSphere Error: `Apply a CSI secret manifest` This PR will fix an issue that you will see on 2nd deploy when deploying External vSphere How to re-produce: 1. Set custom `vsphere_csi_namespace: "vmware-system-csi"` 2. Deploy as usual 3. Observe no errors 4. Deploy 2nd time without `reset` 5. Playbook fails with: ``` TASK [kubernetes-apps/csi_driver/vsphere : vSphere CSI Driver | Apply a CSI secret manifest] fatal: [node-00]: FAILED! => changed=true censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result' ``` * create namespace if does not exist * lint fix * try to fix lint errors * fix `too few spaces before comment` * change the order of applied manifests * typo --- .../csi_driver/vsphere/tasks/main.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/roles/kubernetes-apps/csi_driver/vsphere/tasks/main.yml b/roles/kubernetes-apps/csi_driver/vsphere/tasks/main.yml index 5983fa095..bb0161429 100644 --- a/roles/kubernetes-apps/csi_driver/vsphere/tasks/main.yml +++ b/roles/kubernetes-apps/csi_driver/vsphere/tasks/main.yml @@ -27,19 +27,6 @@ register: vsphere_csi_manifests when: inventory_hostname == groups['kube_control_plane'][0] -- name: vSphere CSI Driver | Generate a CSI secret manifest - command: "{{ kubectl }} create secret generic vsphere-config-secret --from-file=csi-vsphere.conf={{ kube_config_dir }}/vsphere-csi-cloud-config -n {{ vsphere_csi_namespace }} --dry-run --save-config -o yaml" - register: vsphere_csi_secret_manifest - when: inventory_hostname == groups['kube_control_plane'][0] - no_log: "{{ not (unsafe_show_logs|bool) }}" - -- name: vSphere CSI Driver | Apply a CSI secret manifest - command: - cmd: "{{ kubectl }} apply -f -" - stdin: "{{ vsphere_csi_secret_manifest.stdout }}" - when: inventory_hostname == groups['kube_control_plane'][0] - no_log: "{{ not (unsafe_show_logs|bool) }}" - - name: vSphere CSI Driver | Apply Manifests kube: kubectl: "{{ bin_dir }}/kubectl" @@ -52,3 +39,16 @@ - not item is skipped loop_control: label: "{{ item.item }}" + +- name: vSphere CSI Driver | Generate a CSI secret manifest + command: "{{ kubectl }} create secret generic vsphere-config-secret --from-file=csi-vsphere.conf={{ kube_config_dir }}/vsphere-csi-cloud-config -n {{ vsphere_csi_namespace }} --dry-run --save-config -o yaml" + register: vsphere_csi_secret_manifest + when: inventory_hostname == groups['kube_control_plane'][0] + no_log: "{{ not (unsafe_show_logs|bool) }}" + +- name: vSphere CSI Driver | Apply a CSI secret manifest + command: + cmd: "{{ kubectl }} apply -f -" + stdin: "{{ vsphere_csi_secret_manifest.stdout }}" + when: inventory_hostname == groups['kube_control_plane'][0] + no_log: "{{ not (unsafe_show_logs|bool) }}"