|
| 1 | +--- |
| 2 | +# We follow the procedure at: |
| 3 | +# https://docs.openshift.com/container-platform/4.10/post_installation_configuration/machine-configuration-tasks.html#installation-special-config-chrony_post-install-machine-configuration-tasks |
| 4 | +- name: Install Butane |
| 5 | + become: yes |
| 6 | + ansible.builtin.get_url: |
| 7 | + url: https://mirror.openshift.com/pub/openshift-v4/clients/butane/latest/butane |
| 8 | + dest: /usr/local/bin/butane |
| 9 | + mode: u=rwx,g=rwx,o=rwx |
| 10 | + |
| 11 | +- name: Get OCP GA version from release.txt and Build the chronyc manifest |
| 12 | + block: |
| 13 | + - name: Download the OCP GA version from openshift mirror |
| 14 | + ansible.builtin.get_url: |
| 15 | + url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/release.txt |
| 16 | + dest: /tmp/release.txt |
| 17 | + mode: u=rw,g=rw,o=r |
| 18 | + |
| 19 | + - name: Extract OpenShift version |
| 20 | + ansible.builtin.shell: | |
| 21 | + grep -oP "Version:\s*\K4\.\d+" /tmp/release.txt |
| 22 | + changed_when: false |
| 23 | + register: openshift_ga_version |
| 24 | + |
| 25 | + - name: Set ocp_latest_ga variable |
| 26 | + ansible.builtin.set_fact: |
| 27 | + ocp_latest_ga: "{{ openshift_ga_version.stdout }}" |
| 28 | + |
| 29 | + - name: Build the chronyc manifest |
| 30 | + vars: |
| 31 | + ntp_server: "{{ openshift_mirror | default(False) | ternary(installer_vm.installer_fqdn, restricted_network.installer_ip) }}" |
| 32 | + ansible.builtin.template: |
| 33 | + src: 99-node-chronyc.j2 |
| 34 | + dest: "{{ home_dir }}/99-{{ item }}-chrony" |
| 35 | + mode: u=rw,g=rw,o=r |
| 36 | + loop: |
| 37 | + - worker |
| 38 | + - master |
| 39 | + |
| 40 | +# Use Butane to translate a human readable Butane config into a machine readable Ignition config |
| 41 | +- name: Build the chrony machine config |
| 42 | + ansible.builtin.shell: | |
| 43 | + butane {{ home_dir }}/99-{{ item }}-chrony -o {{ home_dir }}/99-{{ item }}-chrony.yaml |
| 44 | + changed_when: true |
| 45 | + loop: |
| 46 | + - worker |
| 47 | + - master |
| 48 | + |
| 49 | +- name: Apply the chrony manifest |
| 50 | + kubernetes.core.k8s: |
| 51 | + state: present |
| 52 | + src: "{{ home_dir }}/99-{{ item }}-chrony.yaml" |
| 53 | + loop: |
| 54 | + - worker |
| 55 | + - master |
| 56 | + environment: |
| 57 | + KUBECONFIG: "{{ kubeconfig }}" |
| 58 | + |
| 59 | +- name: Wait for the MCP to finish the cluster updates |
| 60 | + ansible.builtin.include_role: |
| 61 | + name: tools_cluster_checks |
| 62 | + tasks_from: wait_mcp_updated.yml |
| 63 | + |
| 64 | +- name: Wait until cluster nodes are ready |
| 65 | + ansible.builtin.include_role: |
| 66 | + name: tools_cluster_checks |
| 67 | + tasks_from: wait_until_nodes_ready.yml |
| 68 | + |
| 69 | +# Go over all the OCP nodes and check that NTP is configured correctly by checking that the Stratum from |
| 70 | +# The chronyc tracking command is not 0 in any of them |
| 71 | +- name: Check that the NTP server is reachable from all the OCP nodes |
| 72 | + ansible.builtin.shell: | |
| 73 | + set -o pipefail && |
| 74 | + for i in $(oc get nodes -o name); |
| 75 | + do oc debug -q $i -- chroot /host sudo chronyc tracking|awk '/Stratum/{print $3}'; done | tr -d '\n' | awk '/0/{exit 1}' |
| 76 | + environment: |
| 77 | + KUBECONFIG: "{{ kubeconfig }}" |
| 78 | + changed_when: false |
| 79 | + register: ntp_output |
| 80 | + until: ntp_output is not failed |
| 81 | + retries: 5 |
| 82 | + delay: 30 |
0 commit comments