From 968666ae09ed1d7dc2e11955e2b14aeb59b4bb24 Mon Sep 17 00:00:00 2001
From: entlein <einentlein@gmail.com>
Date: Thu, 30 Jun 2022 16:14:27 +0200
Subject: [PATCH]  adding heuristic wait loops to make sure CCM has had time
 enough to boot

---
 roles/rke2/tasks/fix_selinux.yml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/roles/rke2/tasks/fix_selinux.yml b/roles/rke2/tasks/fix_selinux.yml
index e35389f..1f5419c 100644
--- a/roles/rke2/tasks/fix_selinux.yml
+++ b/roles/rke2/tasks/fix_selinux.yml
@@ -1,14 +1,23 @@
+- name: Sleep for 45 seconds so that the helm operator has deployed the deamonset
+  ansible.builtin.wait_for:
+    timeout: 45
+  delegate_to: localhost
+
 - name: kill the openstack ccm pods to make sure they boot in permissive mode
   shell: "/var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml rollout restart -n kube-system ds openstack-cloud-controller-manager "
   register: openstack_ccm_ready
+  until: openstack_ccm_ready.sdtout
+  retries: 2
+  delay: 30
   when: ( 'master' in group_names )
+  ignore_errors: True
 
-
-- name: Sleep for 300 seconds and continue with play
+- name: Sleep for another 30 seconds so that the OS-CCM has had time to boot up
   ansible.builtin.wait_for:
     timeout: 30
   delegate_to: localhost
 
+
 # - name: Wait for all control-plane pods to become created
 #   shell: "/var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get po --namespace=kube-system --selector tier=control-plane --output=jsonpath='{.items[*].metadata.name}'"
 #   register: control_plane_pods_created
-- 
GitLab