Wolfgang Kulhanek
2020-02-20 27c349da4de291ab35f1ad9a75774fe2f3ab9cb4
Fix workshop restart logic (#1171)

* Add ansible_python_interpreter to ensure cluster recovery works.

* Fix cluster start for real (hopefully?)
1 files modified
25 ■■■■■ changed files
ansible/configs/ocp4-workshop/lifecycle.yml 25 ●●●●● patch | view | raw | blame | history
ansible/configs/ocp4-workshop/lifecycle.yml
@@ -91,9 +91,9 @@
          template:
            dest: "{{ output_dir }}/status.txt"
            src: files/status.j2
- name: Run recover cluster actions
  hosts: localhost
  hosts: bastions
  run_once: true
  become: false
  gather_facts: false
@@ -101,8 +101,8 @@
  - name: Set Ansible Python interpreter to k8s virtualenv
    set_fact:
      ansible_python_interpreter: /opt/virtualenvs/k8s/bin/python
  - name: Recover cluster if it missed cert rotation
    delegate_to: "{{ groups['bastions'] | first }}"
    when: ACTION == 'start'
    block:
    - name: Wait (default 3m) for Nodes to settle and pods to start
@@ -113,12 +113,14 @@
      k8s_facts:
        api_version: certificates.k8s.io/v1beta1
        kind: CertificateSigningRequest
        # Field selectors don't seem to work
        # field_selectors:
        # - status.conditions[0].type="Pending"
      register: r_csrs
    - when: r_csrs.resources | length > 0
      name: Approve all Pending CSRs
    - name: Approve all Pending CSRs
      when: r_csrs.resources | length > 0
      command: "oc adm certificate approve {{ item.metadata.name }}"
      # when: item.status.conditions[0].type == "Pending"
      loop: "{{ r_csrs.resources }}"
    # TODO: Implement proper loop to watch for incoming CSRS while we are
@@ -131,11 +133,12 @@
      k8s_facts:
        api_version: certificates.k8s.io/v1beta1
        kind: CertificateSigningRequest
        # Field selectors don't seem to work
        # field_selectors:
        # - status.conditions[0].type = "Pending"
      register: r_new_csrs
    - when: r_csrs.resources | length > 0
      name: Approve all Pending CSRs
    - name: Approve all additional Pending CSRs
      when: r_new_csrs.resources | length > 0
      command: "oc adm certificate approve {{ item.metadata.name }}"
      # when: item.status.conditions[0].type == "Pending"
      loop: "{{ r_new_csrs.resources }}"
      loop: "{{ r_new_csrs.resources }}"