From cf1d7b9c3f100f5f1d9d0e96aa6e826b595dcf11 Mon Sep 17 00:00:00 2001 From: Klaus Smolin <88041391+smolin-de@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:04:28 +0200 Subject: [PATCH] feat: Detect automatically required RHCOS images for compute nodes (#193) This patch detects the required RHCOS images to install a compute node. Signed-off-by: Klaus Smolin --- playbooks/create_compute_node.yaml | 45 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/playbooks/create_compute_node.yaml b/playbooks/create_compute_node.yaml index 8a5eed2d..f92749b0 100644 --- a/playbooks/create_compute_node.yaml +++ b/playbooks/create_compute_node.yaml @@ -9,11 +9,6 @@ # hostname: # host_arch: # -# rhcos_download_url: -# rhcos_live_kernel: -# rhcos_live_initrd: -# rhcos_live_rootfs: -# # Execute the playbook with '--extra-vars' option. # E.g.: # ansible-playbook playbooks/add_compute_node.yaml --extra-vars "@extra-cnode1.yml" @@ -37,6 +32,46 @@ ansible.builtin.fail: msg: "See above error!" + - name: Get RHCOS iso download url from machine-config-operator + ansible.builtin.shell: | + set -o pipefail + oc -n openshift-machine-config-operator get configmap/coreos-bootimages -o jsonpath='{.data.stream}' \ + | jq -r '.architectures.{{ day2_compute_node.host_arch }}.artifacts.metal.formats.iso.disk.location' + register: _rhcos_iso_dl_url + + - name: Get RHCOS kernel download url from machine-config-operator + ansible.builtin.shell: | + set -o pipefail + oc -n openshift-machine-config-operator get configmap/coreos-bootimages -o jsonpath='{.data.stream}' \ + | jq -r '.architectures.{{ day2_compute_node.host_arch }}.artifacts.metal.formats.pxe.kernel.location' + register: _rhcos_kernel_dl_url + + - name: Get RHCOS initrd download url from machine-config-operator + ansible.builtin.shell: | + set -o pipefail + oc -n openshift-machine-config-operator get configmap/coreos-bootimages -o jsonpath='{.data.stream}' \ + | jq -r '.architectures.{{ day2_compute_node.host_arch }}.artifacts.metal.formats.pxe.initramfs.location' + register: _rhcos_initrd_dl_url + + - name: Get RHCOS rootfs download url from machine-config-operator + ansible.builtin.shell: | + set -o pipefail + oc -n openshift-machine-config-operator get configmap/coreos-bootimages -o jsonpath='{.data.stream}' \ + | jq -r '.architectures.{{ day2_compute_node.host_arch }}.artifacts.metal.formats.pxe.rootfs.location' + register: _rhcos_rootfs_dl_url + + - name: Redefine RHCOS variables + ansible.builtin.set_fact: + rhcos_live_kernel: "{{ (_rhcos_kernel_dl_url.stdout | split('/') | last) }}" + rhcos_live_initrd: "{{ (_rhcos_initrd_dl_url.stdout | split('/') | last) }}" + rhcos_live_rootfs: "{{ (_rhcos_rootfs_dl_url.stdout | split('/') | last) }}" + rhcos_live_iso: "{{ (_rhcos_iso_dl_url.stdout.split('/')[-1]) }}" + + - name: Redefine RHCOS download url + ansible.builtin.set_fact: + # Assume all images have same download location + rhcos_download_url: "{{ (_rhcos_rootfs_dl_url.stdout | replace(rhcos_live_rootfs, '')) }}" + roles: - role: common - role: print_node_status