|
| 1 | +--- |
| 2 | +- name: Set Facts to recurse with |
| 3 | + set_fact: |
| 4 | + r_qry: "{{ qry }}" |
| 5 | + r_worker_counter: "{{ worker_counter }}" |
| 6 | + |
| 7 | +- name: approve CSRs and check if nodes have joined the cluster |
| 8 | + block: |
| 9 | + - name: Increment the retry count |
| 10 | + set_fact: |
| 11 | + retry: "{{ 0 if retry is undefined else retry | int + 1 }}" |
| 12 | + |
| 13 | + - name: Pause during loop |
| 14 | + pause: |
| 15 | + seconds: "30" |
| 16 | + when: retry|int > 0 |
| 17 | + |
| 18 | + - name: Get CSRs |
| 19 | + shell: | |
| 20 | + KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc get csr -o json |
| 21 | + register: oc_get_csr |
| 22 | + |
| 23 | + - name: Approve pending CSRs |
| 24 | + shell: | |
| 25 | + KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc adm certificate approve {{ item.metadata.name }} |
| 26 | + loop: "{{ oc_get_csr.stdout | from_json | json_query(qry) }}" |
| 27 | + loop_control: |
| 28 | + label: "{{ item.metadata.name }}" |
| 29 | + |
| 30 | + - name: Get worker node count |
| 31 | + shell: | |
| 32 | + KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc get nodes | {{ worker_counter }} |
| 33 | + register: oc_get_nodes_workers |
| 34 | + |
| 35 | + - name: Current Worker Node Count |
| 36 | + debug: |
| 37 | + var: oc_get_nodes_workers.stdout |
| 38 | + |
| 39 | + - name: Waiting for Worker Node Count |
| 40 | + debug: |
| 41 | + msg: "{{ current_worker_count+scale_out_count }}" |
| 42 | + |
| 43 | + - name: Raise fail to trigger retry if all nodes didn't meet requirments |
| 44 | + fail: |
| 45 | + msg: All nodes have not met check requirements |
| 46 | + when: oc_get_nodes_workers.stdout|int < current_worker_count+scale_out_count |
| 47 | + rescue: |
| 48 | + - name: Fail on maximum retry count |
| 49 | + fail: |
| 50 | + msg: Maximum retries reached |
| 51 | + when: retry | int == 540 |
| 52 | + |
| 53 | + - name: Retry the check |
| 54 | + include_tasks: check_nodes_joined.yml |
| 55 | + vars: |
| 56 | + qry: "{{ r_qry }}" |
| 57 | + worker_counter: "{{ r_worker_counter }}" |
0 commit comments