From 68606663247775bf103ac792360f54579a13c005 Mon Sep 17 00:00:00 2001 From: karmab Date: Thu, 21 Dec 2023 10:54:10 +0100 Subject: [PATCH] migrate to aicli --- aicli_parameters.yml | 40 +++++++ bin/clean.sh | 3 - envfiles/bashrc | 11 +- kcli_pre.sh | 5 + plans/kcli_plan.yml | 10 +- plans/kcli_plan_default.yml | 15 +-- scripts/00_virtual.sh | 7 +- ...ch_installconfig.sh => 01_patch_config.sh} | 7 -- scripts/02_packages.sh | 47 ++------ scripts/03_cache.sh | 56 --------- ...ed_mirror.sh => 03_disconnected_mirror.sh} | 36 ------ ...onnected_olm.sh => 03_disconnected_olm.sh} | 0 ...nected_quay.sh => 03_disconnected_quay.sh} | 0 ...egistry.sh => 03_disconnected_registry.sh} | 0 scripts/{05_nbde.sh => 04_nbde.sh} | 0 scripts/{06_ntp.sh => 05_ntp.sh} | 0 scripts/06_deploy_openshift.sh | 36 ++++++ scripts/07_deploy_openshift.sh | 111 ------------------ scripts/{08_nfs.sh => 07_nfs.sh} | 0 ...{09_post_install.sh => 08_post_install.sh} | 0 scripts/{10_apps.sh => 09_apps.sh} | 0 scripts/launch_steps.sh | 54 ++++----- 22 files changed, 129 insertions(+), 309 deletions(-) create mode 100644 aicli_parameters.yml delete mode 100755 bin/clean.sh rename scripts/{01_patch_installconfig.sh => 01_patch_config.sh} (51%) delete mode 100755 scripts/03_cache.sh rename scripts/{04_disconnected_mirror.sh => 03_disconnected_mirror.sh} (57%) rename scripts/{04_disconnected_olm.sh => 03_disconnected_olm.sh} (100%) rename scripts/{04_disconnected_quay.sh => 03_disconnected_quay.sh} (100%) rename scripts/{04_disconnected_registry.sh => 03_disconnected_registry.sh} (100%) rename scripts/{05_nbde.sh => 04_nbde.sh} (100%) rename scripts/{06_ntp.sh => 05_ntp.sh} (100%) create mode 100755 scripts/06_deploy_openshift.sh delete mode 100755 scripts/07_deploy_openshift.sh rename scripts/{08_nfs.sh => 07_nfs.sh} (100%) rename scripts/{09_post_install.sh => 08_post_install.sh} (100%) rename scripts/{10_apps.sh => 09_apps.sh} (100%) diff --git a/aicli_parameters.yml b/aicli_parameters.yml new file mode 100644 index 00000000..04bbc780 --- /dev/null +++ b/aicli_parameters.yml @@ -0,0 +1,40 @@ +{% if virtual_ctlplanes %} +{% set extra_ctlplanes = [] %} +{% for num in range(0, virtual_ctlplanes_number) %} +{% do extra_ctlplanes.append([]) %} +{% endfor %} +{% set ctlplanes = extra_ctlplanes + ctlplanes %} +{% endif %} +{% if virtual_workers and virtual_workers_deploy %} +{% set extra_workers = [] %} +{% for num in range(0, virtual_workers_number) %} +{% do extra_workers.append([]) %} +{% endfor %} +{% set workers = extra_workers + workers %} +{% endif %} +base_dns_domain: {{ domain }} +api_vip: {{ api_ip }} +ingress_vip: {{ ingress_ip }} +hosts: +{% for ctlplane in ctlplanes %} +{% set num = loop.index0|string %} +- name: {{ cluster }}-ctlplane-{{ num }} + role: master + url: {{ ctlplane['redfish_address']|default("CHANGEME:9000/redfish/v1/Systems/kcli/%s-ctlplane-%s" % (cluster, num)) }} + user: {{ ctlplane['bmc_user']|default(bmc_user) }} + password: {{ ctlplane['bmc_password']|default(bmc_password) }} +{% if 'disk' in ctlplane %} + disk: "/dev/{{ ctlplane['disk'] | basename }}" +{% endif %} +{% endfor %} +{% for worker in workers %} +{% set num = loop.index0|string %} +- name: {{ cluster }}-worker-{{ num }} + role: worker + url: {{ worker['redfish_address']|default("CHANGEME:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }} + user: {{ worker['bmc_user']|default(bmc_user) }} + password: {{ worker['bmc_password']|default(bmc_password) }} +{% if 'disk' in worker %} + disk: "/dev/{{ worker['disk'] | basename }}" +{% endif %} +{% endfor %} diff --git a/bin/clean.sh b/bin/clean.sh deleted file mode 100755 index cdff4f0d..00000000 --- a/bin/clean.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -[ -d /root/ocp ] && rm -rf /root/ocp diff --git a/envfiles/bashrc b/envfiles/bashrc index 61f5b70e..e709caa1 100644 --- a/envfiles/bashrc +++ b/envfiles/bashrc @@ -1,8 +1,4 @@ # .bashrc -{% set libvirt_user = 'root' if config_user == 'apache' else config_user %} -{% set libvirt_ip = config_host if config_host not in ['127.0.0.1', 'localhost'] else baremetal_net|local_ip %} -{% set libvirt_ip = libvirt_ip|replace(':', '-') + '.sslip.io' %} -{% set libvirt_url = 'qemu+ssh://' + libvirt_user + '@' + libvirt_ip + '/system' %} # User specific aliases and functions @@ -14,13 +10,8 @@ alias mv='mv -i' if [ -f /etc/bashrc ]; then . /etc/bashrc fi -export KUBECONFIG=/root/ocp/auth/kubeconfig -export OS_CLOUD=metal3-bootstrap +export KUBECONFIG=/root/kubeconfig.{{ kubeconfig }} export PATH=/usr/local/bin:/root/bin:$PATH -export LIBVIRT_DEFAULT_URI={{ libvirt_url }} export REGISTRY_PASSWORD={{ disconnected_password }} export REGISTRY_USER={{ disconnected_user }} - -alias hypershift='podman run -it --rm --security-opt label=disable --entrypoint=/usr/bin/hypershift -e KUBECONFIG=/k/kubeconfig -v /root/ocp/auth:/k quay.io/hypershift/hypershift-operator:latest' - export PYTHONUNBUFFERED=true diff --git a/kcli_pre.sh b/kcli_pre.sh index 5c05cc23..d26fa2ed 100755 --- a/kcli_pre.sh +++ b/kcli_pre.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +# OFFLINE TOKEN +{% if saas %} +[ ! -f {{ offlinetoken }} ] && echo offlinetoken not found in {{ offlinetoken }} && exit 1 +{% endif %} + # NETWORK CHECK {% if baremetal_cidr == None %} echo baremetal_cidr not set. No network, no party! diff --git a/plans/kcli_plan.yml b/plans/kcli_plan.yml index 5c26f66c..06dbd723 100644 --- a/plans/kcli_plan.yml +++ b/plans/kcli_plan.yml @@ -21,7 +21,7 @@ {% if deploy_openshift %} notifyscript: {{ notifyscript }} {% elif launch_steps %} - notifycmd: /root/bin/openshift-install version + notifycmd: aicli list cluster {% else %} notifycmd: echo machine $(hostname) ready at $(hostname -I) {% endif %} @@ -43,7 +43,7 @@ disks: - {{ installer_disk_size or disk_size }} files: - - install-config.yaml + - aicli_parameters.yml {% if motd != None %} - path: /etc/motd origin: {{ motd }} @@ -61,7 +61,11 @@ - mirror-registry/quay_haproxy.cfg {% endif %} - origin: {{ pullsecret }} - path: /root/openshift_pull.json + path: /root/openshift_pull.json +{% if saas %} + - origin: {{ offlinetoken }} + path: /root/.aicli/offlinetoken.txt +{% endif %} - path: /etc/systemd/system/registry.service origin: bin/registry.service {% for ca in cas %} diff --git a/plans/kcli_plan_default.yml b/plans/kcli_plan_default.yml index 3340d44f..f617947c 100644 --- a/plans/kcli_plan_default.yml +++ b/plans/kcli_plan_default.yml @@ -1,7 +1,6 @@ info: | This deploys a vm where - - openshift-baremetal-install is downloaded - - caches rhcos bootstrap image + - aicli is downloaded - stop the nodes to deploy through redfish - launch the install against a set of baremetal nodes (and optionally virtual ctlplanes) It can be used with a centos8stream or rhel8 vm (which required to set rhn credentials in your kcli config) @@ -39,12 +38,6 @@ image_url: numcpus: 16 rhnregister: true rhnwait: 30 -baremetal_noprovisioning_ip: -baremetal_noprovisioning_bootstrap_ip: -baremetal_bootstrap_mac: -baremetal_bootstrap_ip: -baremetal_bootstrap_os_image: -baremetal_cluster_os_image: bmc_user: root bmc_password: calvin bmc_reset: false @@ -53,7 +46,6 @@ baremetal_macs: [] baremetal_ips: [] pullsecret: openshift_pull.json notifyscript: scripts/notify.sh -virtual_protocol: ipmi notify: false launch_steps: true deploy_openshift: true @@ -87,8 +79,6 @@ cas: [] nbde: false ntp: false ntp_server: 0.rhel.pool.ntp.org -model: dell -patch_rhcos_image: false apps: [] localhost_fix: false virtual_ctlplanes_static_network: False @@ -105,4 +95,5 @@ wait_for_workers: true wait_for_workers_number: wait_for_workers_timeout: 3600 manifests_dir: manifests -wait_for_workers_exit_if_error: false +saas: true +offlinetoken: ~/.aicli/offlinetoken.txt diff --git a/scripts/00_virtual.sh b/scripts/00_virtual.sh index 1143e4da..cba0794d 100755 --- a/scripts/00_virtual.sh +++ b/scripts/00_virtual.sh @@ -20,9 +20,6 @@ ssh-keyscan -H {{ config_host if config_host not in ['127.0.0.1', 'localhost'] e echo -e "Host=*\nStrictHostKeyChecking=no\n" > /root/.ssh/config IP=$(ip -o addr show $PRIMARY_NIC | head -1 | awk '{print $4}' | cut -d "/" -f 1 | head -1) echo $IP | grep -q ':' && IP=[$IP] -sed -i "s/CHANGEME/$IP/" /root/install-config.yaml +sed -i "s/CHANGEME/$IP/" /root/aicli_parameters.yml -api_vip=$(grep apiVIP /root/install-config.yaml | sed s/apiVIP:// | xargs) -cluster=$(grep -m 1 name /root/install-config.yaml | awk -F: '{print $2}' | xargs) -domain=$(grep baseDomain /root/install-config.yaml | awk -F: '{print $2}' | xargs) -echo $api_vip api.$cluster.$domain >> /etc/hosts +echo {{ api_ip }} api.{{ cluster }}.{{ domain }} >> /etc/hosts diff --git a/scripts/01_patch_installconfig.sh b/scripts/01_patch_config.sh similarity index 51% rename from scripts/01_patch_installconfig.sh rename to scripts/01_patch_config.sh index 5003cb55..57312034 100755 --- a/scripts/01_patch_installconfig.sh +++ b/scripts/01_patch_config.sh @@ -5,10 +5,3 @@ set -euo pipefail [ -d /root/manifests ] || mkdir -p /root/manifests ssh-keyscan -H {{ config_host if config_host not in ['127.0.0.1', 'localhost'] else baremetal_net|local_ip }} >> ~/.ssh/known_hosts echo -e "Host=*\nStrictHostKeyChecking=no\n" > ~/.ssh/config - -{% if not disconnected %} -PULLSECRET=$(cat /root/openshift_pull.json | tr -d [:space:]) -echo -e "pullSecret: |\n $PULLSECRET" >> /root/install-config.yaml -{% endif %} -SSHKEY=$(cat /root/.ssh/id_rsa.pub) -echo -e "sshKey: |\n $SSHKEY" >> /root/install-config.yaml diff --git a/scripts/02_packages.sh b/scripts/02_packages.sh index 749ddc37..056fc630 100755 --- a/scripts/02_packages.sh +++ b/scripts/02_packages.sh @@ -3,53 +3,30 @@ set -euo pipefail dnf -y copr enable karmab/kcli -dnf -y install libvirt-libs libvirt-client ipmitool mkisofs tmux make git bash-completion vim-enhanced kcli +dnf -y install libvirt-libs libvirt-client mkisofs tmux make git bash-completion vim-enhanced kcli dnf -y install python3 +dnf -y copr enable karmab/aicli +dnf -y install aicli +{% if not saas %} +aicli create onprem +export AI_URL=127.0.0.1:8090 +{% endif %} + update-ca-trust extract curl -Ls https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/bin/jq chmod u+x /usr/bin/jq cd /root/bin -curl -k -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz > oc.tar.gz -tar zxf oc.tar.gz -rm -rf oc.tar.gz +kcli download oc mv oc /usr/bin chmod +x /usr/bin/oc -curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl > /usr/bin/kubectl +kcli download kubectl +mv kubectl /usr/bin chmod u+x /usr/bin/kubectl -export PULL_SECRET="/root/openshift_pull.json" -{% if version in ['dev-preview', 'stable'] %} -{% set tag = tag|string %} -{% if tag.split('.')|length > 2 %} -TAG={{ tag }} -{% else %} -TAG={{"latest-" + tag }} -{% endif %} -OCP_REPO={{ 'ocp-dev-preview' if version == 'dev-preview' else 'ocp' }} -export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/$OCP_REPO/$TAG/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}') -{% elif version == 'latest' %} -export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}-{{ tag }}/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}') -{% elif version == 'ci' %} -{% if openshift_image == None %} -{% set openshift_image = tag if '/' in tag|string else "registry.ci.openshift.org/ocp/release:" + tag|string %} -{% endif %} -export OPENSHIFT_RELEASE_IMAGE={{ openshift_image }} -{% elif version == 'nightly' %} -export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://amd64.ocp.releases.ci.openshift.org/api/v1/releasestream/{{ tag|string }}.0-0.nightly/latest | jq -r .pullSpec) -{% endif %} -oc adm release extract --registry-config $PULL_SECRET --command=oc --to /tmp $OPENSHIFT_RELEASE_IMAGE -mv /tmp/oc /root/bin -oc adm release extract --registry-config $PULL_SECRET --command=openshift-baremetal-install --to /root/bin $OPENSHIFT_RELEASE_IMAGE -ln -s /root/bin/openshift-baremetal-install /root/bin/openshift-install -echo $OPENSHIFT_RELEASE_IMAGE > /root/version.txt - -curl -s -L https://github.com/itaysk/kubectl-neat/releases/download/v2.0.3/kubectl-neat_linux_amd64.tar.gz | tar xvz -C /usr/bin/ - -dnf copr enable zaneb/autopage -y -dnf install podman skopeo python3-bmo-log-parse -y +dnf -y install podman skopeo oc completion bash >>/etc/bash_completion.d/oc_completion diff --git a/scripts/03_cache.sh b/scripts/03_cache.sh deleted file mode 100755 index fbf23ca2..00000000 --- a/scripts/03_cache.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -PRIMARY_NIC=$(ls -1 /sys/class/net | grep -v podman | head -1) -export PATH=/root/bin:$PATH -dnf -y install httpd -dnf -y update libgcrypt -systemctl enable --now httpd -cd /var/www/html -if openshift-baremetal-install coreos print-stream-json >/dev/null 2>&1; then - RHCOS_OPENSTACK_URI_FULL=$(openshift-baremetal-install coreos print-stream-json | jq -r '.architectures.x86_64.artifacts.openstack.formats["qcow2.gz"].disk.location') - RHCOS_QEMU_URI_FULL=$(openshift-baremetal-install coreos print-stream-json | jq -r '.architectures.x86_64.artifacts.qemu.formats["qcow2.gz"].disk.location') - RHCOS_QEMU_SHA_UNCOMPRESSED=$(openshift-baremetal-install coreos print-stream-json | jq -r '.architectures.x86_64.artifacts.qemu.formats["qcow2.gz"].disk["uncompressed-sha256"]') - RHCOS_OPENSTACK_SHA_COMPRESSED=$(openshift-baremetal-install coreos print-stream-json | jq -r '.architectures.x86_64.artifacts.openstack.formats["qcow2.gz"].disk["sha256"]') - RHCOS_QEMU_URI=$(basename $RHCOS_QEMU_URI_FULL) - RHCOS_OPENSTACK_URI=$(basename $RHCOS_OPENSTACK_URI_FULL) - time curl -L $RHCOS_QEMU_URI_FULL > $RHCOS_QEMU_URI - time curl -L $RHCOS_OPENSTACK_URI_FULL > $RHCOS_OPENSTACK_URI -else - if [ -z "${COMMIT_ID-}" ] ; then - export COMMIT_ID=$(openshift-baremetal-install version | grep '^built from commit' | awk '{print $4}') - fi - RHCOS_OPENSTACK_URI=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq .images.openstack.path | sed 's/"//g') - RHCOS_QEMU_URI=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq .images.qemu.path | sed 's/"//g') - RHCOS_PATH=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq .baseURI | sed 's/"//g') - RHCOS_QEMU_SHA_UNCOMPRESSED=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq -r '.images.qemu["uncompressed-sha256"]') - RHCOS_OPENSTACK_SHA_COMPRESSED=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq -r '.images.openstack.sha256') - time curl -L $RHCOS_PATH$RHCOS_QEMU_URI > $RHCOS_QEMU_URI - time curl -L $RHCOS_PATH$RHCOS_OPENSTACK_URI > $RHCOS_OPENSTACK_URI -fi - -{% if patch_rhcos_image %} -dnf -y install libguestfs-tools -export LIBGUESTFS_BACKEND=direct -STACK={{ 'dhcp6' if ':' in api_ip and not dualstack else 'dhcp' }} -EXTRACTED_FILE=openstack.qcow2 -gunzip -c $RHCOS_OPENSTACK_URI > $EXTRACTED_FILE -BOOT_DISK=$(virt-filesystems -a $EXTRACTED_FILE -l | grep boot | cut -f1 -d" ") -virt-edit -a $EXTRACTED_FILE -m $BOOT_DISK /boot/loader/entries/ostree-1-rhcos.conf -e "s/^options/options ip=$STACK/" -gzip -c $EXTRACTED_FILE > $RHCOS_OPENSTACK_URI -RHCOS_OPENSTACK_SHA_COMPRESSED=$(sha256sum $RHCOS_OPENSTACK_URI | cut -d " " -f1) -EXTRACTED_FILE=qemu.qcow2 -gunzip -c $RHCOS_QEMU_URI > $EXTRACTED_FILE -BOOT_DISK=$(virt-filesystems -a $EXTRACTED_FILE -l | grep boot | cut -f1 -d" ") -virt-edit -a $EXTRACTED_FILE -m $BOOT_DISK /boot/loader/entries/ostree-1-rhcos.conf -e "s/^options/options ip=$STACK/" -gzip -c $EXTRACTED_FILE > $RHCOS_QEMU_URI -RHCOS_QEMU_SHA_UNCOMPRESSED=$(sha256sum $EXTRACTED_FILE | cut -d " " -f1) -unset LIBGUESTFS_BACKEND -{% endif %} - -SPACES=$(grep apiVIP /root/install-config.yaml | sed 's/apiVIP.*//' | sed 's/ /\\ /'g) -export BAREMETAL_IP=$(ip -o addr show $PRIMARY_NIC | head -1 | awk '{print $4}' | cut -d'/' -f1) -echo $BAREMETAL_IP | grep -q ':' && BAREMETAL_IP=[$BAREMETAL_IP] -sed -i "/apiVIP/i${SPACES}bootstrapOSImage: http://${BAREMETAL_IP}/${RHCOS_QEMU_URI}?sha256=${RHCOS_QEMU_SHA_UNCOMPRESSED}" /root/install-config.yaml -sed -i "/apiVIP/i${SPACES}clusterOSImage: http://${BAREMETAL_IP}/${RHCOS_OPENSTACK_URI}?sha256=${RHCOS_OPENSTACK_SHA_COMPRESSED}" /root/install-config.yaml diff --git a/scripts/04_disconnected_mirror.sh b/scripts/03_disconnected_mirror.sh similarity index 57% rename from scripts/04_disconnected_mirror.sh rename to scripts/03_disconnected_mirror.sh index c80c2f22..b3412a02 100755 --- a/scripts/04_disconnected_mirror.sh +++ b/scripts/03_disconnected_mirror.sh @@ -36,42 +36,6 @@ EXTRA_OCP_RELEASE={{ release.split(':')[1] }} oc adm release mirror -a $PULL_SECRET --from={{ release }} --to-release-image=${LOCAL_REG}/openshift/release-images:${EXTRA_OCP_RELEASE} --to=${LOCAL_REG}/openshift/release {% endfor %} -if [ "$(grep imageContentSources /root/install-config.yaml)" == "" ] ; then -cat << EOF >> /root/install-config.yaml -imageContentSources: -- mirrors: - - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release - source: quay.io/openshift-release-dev/ocp-v4.0-art-dev -- mirrors: - - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images -{% if version == 'ci' %} - source: registry.ci.openshift.org/ocp/release -{% elif version == 'nightly' %} - source: quay.io/openshift-release-dev/ocp-release-nightly -{% else %} - source: quay.io/openshift-release-dev/ocp-release -{% endif %} -EOF -else - IMAGECONTENTSOURCES="- mirrors:\n - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release\n source: quay.io/openshift-release-dev/ocp-v4.0-art-dev\n- mirrors:\n - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images\n source: registry.ci.openshift.org/ocp/release" - sed -i "/imageContentSources/a${IMAGECONTENTSOURCES}" /root/install-config.yaml -fi - -if [ "$(grep additionalTrustBundle /root/install-config.yaml)" == "" ] ; then - echo "additionalTrustBundle: |" >> /root/install-config.yaml - sed -e 's/^/ /' /opt/registry/certs/domain.crt >> /root/install-config.yaml -else - LOCALCERT="-----BEGIN CERTIFICATE-----\n $(grep -v CERTIFICATE /opt/registry/certs/domain.crt | tr -d '[:space:]')\n -----END CERTIFICATE-----" - sed -i "/additionalTrustBundle/a${LOCALCERT}" /root/install-config.yaml - sed -i 's/^-----BEGIN/ -----BEGIN/' /root/install-config.yaml -fi -echo $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images:$OCP_RELEASE > /root/version.txt - -if [ "$(grep pullSecret /root/install-config.yaml)" == "" ] ; then -DISCONNECTED_PULLSECRET=$(cat /root/disconnected_pull.json | tr -d [:space:]) -echo -e "pullSecret: |\n $DISCONNECTED_PULLSECRET" >> /root/install-config.yaml -fi - cp /root/machineconfigs/99-operatorhub.yaml /root/manifests {% for image in disconnected_extra_images %} diff --git a/scripts/04_disconnected_olm.sh b/scripts/03_disconnected_olm.sh similarity index 100% rename from scripts/04_disconnected_olm.sh rename to scripts/03_disconnected_olm.sh diff --git a/scripts/04_disconnected_quay.sh b/scripts/03_disconnected_quay.sh similarity index 100% rename from scripts/04_disconnected_quay.sh rename to scripts/03_disconnected_quay.sh diff --git a/scripts/04_disconnected_registry.sh b/scripts/03_disconnected_registry.sh similarity index 100% rename from scripts/04_disconnected_registry.sh rename to scripts/03_disconnected_registry.sh diff --git a/scripts/05_nbde.sh b/scripts/04_nbde.sh similarity index 100% rename from scripts/05_nbde.sh rename to scripts/04_nbde.sh diff --git a/scripts/06_ntp.sh b/scripts/05_ntp.sh similarity index 100% rename from scripts/06_ntp.sh rename to scripts/05_ntp.sh diff --git a/scripts/06_deploy_openshift.sh b/scripts/06_deploy_openshift.sh new file mode 100755 index 00000000..295c3fa0 --- /dev/null +++ b/scripts/06_deploy_openshift.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd /root +export PATH=/root/bin:$PATH +export HOME=/root +export KUBECONFIG=/root/kubeconfig.{{ cluster }} +[ -d /root/manifests ] || mkdir -p /root/manifests + +{% for ctlplane in ctlplanes %} +kcli stop baremetal-host -P url={{ ctlplane["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-ctlplane-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }} +{% endfor %} +{% for worker in workers %} +kcli stop baremetal-host -P url={{ worker["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }} +{% if bmc_reset %} +kcli reset baremetal-host -P url={{ worker["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }} +{% endif %} +{% endfor %} + +{% if localhost_fix %} +cp /root/machineconfigs/99-localhost-fix*.yaml /root/manifests +{% endif %} +{% if monitoring_retention != None %} +cp /root/machineconfigs/99-monitoring.yaml /root/manifests +{% endif %} +find manifests -type f -empty -print -delete +grep -q "{{ api_ip }} api.{{ cluster }}.{{ domain }}" /etc/hosts || echo {{ api_ip }} api.{{ cluster }}.{{ domain }} >> /etc/hosts + +aicli create deployment {{ cluster }} +aicli download kubeconfig --path /root +{% if virtual_ctlplanes %} +for node in $(oc get nodes --selector='node-role.kubernetes.io/master' -o name) ; do + oc label $node node-role.kubernetes.io/virtual="" +done +{% endif %} diff --git a/scripts/07_deploy_openshift.sh b/scripts/07_deploy_openshift.sh deleted file mode 100755 index 57ba16bb..00000000 --- a/scripts/07_deploy_openshift.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cd /root -export PATH=/root/bin:$PATH -export HOME=/root -export KUBECONFIG=/root/ocp/auth/kubeconfig -export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE=$(cat /root/version.txt) -bash /root/bin/clean.sh || true -mkdir -p ocp/openshift -python3 /root/bin/redfish.py off -{% if bmc_reset %} -{% for worker in workers %} -{% if worker['model']|default('kvm') in ("dell", "hp", "hpe") %} -worker_ip={{ worker["redfish_address"] }} -{% if worker['model'] == "dell" %} -bmc_reset_url="https://${worker_ip}/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset" -{% elif worker['model'] in ("hp", "hpe") %} -bmc_reset_url="https://${worker_ip}/redfish/v1/Managers/1/Actions/Manager.Reset" -{% endif %} -curl -i -k -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u {{ bmc_user }}:{{ bmc_password }} --data '{"ResetType":"GracefulRestart"}' $bmc_reset_url -if [[ $? -eq 0 ]]; then # Can be implicit, but explicit for visibility - echo "BMC ${worker_ip} restarting!" - sleep 30 # Time to start restart -else - echo "ERROR: BMC ${worker_ip} fails to restart" -fi -{% endif %} -{% endfor %} -{% endif %} - -{% for worker in workers %} -{% if worker['model']|default('kvm') in ("dell", "hp", "hpe") %} -worker_ip={{ worker["redfish_address"] }} -SECONDS_PASSED=0 -SECONDS_TIMEOUT=300 -until curl -k https://${worker_ip}/redfish/v1/ > /dev/null -do - echo "Waiting for worker ${worker_ip} to come back up after bmc reset..." - SECONDS_INTERVAL=15 - sleep $SECONDS_INTERVAL - SECONDS_PASSED=$((SECONDS_PASSED + SECONDS_INTERVAL)) - if [[ "${SECONDS_PASSED}" -gt "${SECONDS_TIMEOUT}" ]]; then - echo "Timeout waiting for BMC to come back up, something failed, check ${worker_ip}" - exit 1 - fi -done -echo "BMC of worker is up! (${worker_ip})" -{% endif %} -{% endfor %} -cp install-config.yaml ocp -openshift-baremetal-install --dir ocp --log-level debug create manifests -{% if localhost_fix %} -cp /root/machineconfigs/99-localhost-fix*.yaml /root/manifests -{% endif %} -{% if monitoring_retention != None %} -cp /root/machineconfigs/99-monitoring.yaml /root/manifests -{% endif %} -find manifests -type f -empty -print -delete -cp manifests/*y*ml >/dev/null 2>&1 ocp/openshift || true -grep -q "{{ api_ip }} api.{{ cluster }}.{{ domain }}" /etc/hosts || echo {{ api_ip }} api.{{ cluster }}.{{ domain }} >> /etc/hosts -{% if baremetal_bootstrap_ip != None %} -openshift-baremetal-install --dir ocp --log-level debug create ignition-configs -NIC=ens3 -NICDATA="$(cat /root/static_network/ifcfg-bootstrap | base64 -w0)" -cp /root/ocp/bootstrap.ign /root/ocp/bootstrap.ign.ori -cat /root/ocp/bootstrap.ign.ori | jq ".storage.files |= . + [{\"filesystem\": \"root\", \"mode\": 420, \"path\": \"/etc/sysconfig/network-scripts/ifcfg-$NIC\", \"contents\": {\"source\": \"data:text/plain;charset=utf-8;base64,$NICDATA\", \"verification\": {}}}]" > /root/ocp/bootstrap.ign -{% endif %} - -openshift-baremetal-install --dir ocp --log-level debug create cluster -openshift-baremetal-install --dir ocp --log-level debug wait-for install-complete || openshift-baremetal-install --dir ocp --log-level debug wait-for install-complete -{% if virtual_ctlplanes %} -for node in $(oc get nodes --selector='node-role.kubernetes.io/master' -o name) ; do - oc label $node node-role.kubernetes.io/virtual="" -done -{% endif %} - -set +e -{% if wait_for_workers_number != None %} -TOTAL_WORKERS={{ wait_for_workers_number }} -{% else %} -TOTAL_WORKERS=$(grep 'role: worker' /root/install-config.yaml | wc -l) -{% endif %} -if [ "$TOTAL_WORKERS" -gt "0" ] ; then -CURRENT_WORKERS=$(oc get nodes --selector='node-role.kubernetes.io/worker' | grep -v ctlplane | grep -c " Ready") -{% if wait_for_workers or wait_for_workers_number != None %} - TIMEOUT=0 - WAIT_TIMEOUT={{ wait_for_workers_timeout }} - until [ "$CURRENT_WORKERS" == "$TOTAL_WORKERS" ] ; do - if [ "$TIMEOUT" -gt "$WAIT_TIMEOUT" ] ; then - echo "Timeout waiting for Current workers number $CURRENT_WORKERS to match expected worker number $TOTAL_WORKERS" - {% if wait_for_workers_exit_if_error %} - exit 1 - {% else %} - break - {% endif %} - fi - CURRENT_WORKERS=$(oc get nodes --selector='node-role.kubernetes.io/worker' | grep -v ctlplane | grep -c " Ready") - echo "Waiting for all workers to show up..." - sleep 5 - TIMEOUT=$(($TIMEOUT + 5)) - done -{% else %} - if [ "$CURRENT_WORKERS" != "$TOTAL_WORKERS" ] ; then - echo "Beware, Current workers number $CURRENT_WORKERS doesnt match expected worker number $TOTAL_WORKERS" - sleep 5 - fi -{% endif %} -fi -set +e diff --git a/scripts/08_nfs.sh b/scripts/07_nfs.sh similarity index 100% rename from scripts/08_nfs.sh rename to scripts/07_nfs.sh diff --git a/scripts/09_post_install.sh b/scripts/08_post_install.sh similarity index 100% rename from scripts/09_post_install.sh rename to scripts/08_post_install.sh diff --git a/scripts/10_apps.sh b/scripts/09_apps.sh similarity index 100% rename from scripts/10_apps.sh rename to scripts/09_apps.sh diff --git a/scripts/launch_steps.sh b/scripts/launch_steps.sh index bcb1d84c..9dc7d067 100755 --- a/scripts/launch_steps.sh +++ b/scripts/launch_steps.sh @@ -15,55 +15,47 @@ echo -e "${blue}************ RUNNING 00_virtual.sh ************${clear}" /root/scripts/00_virtual.sh || exit 1 {% endif %} -echo -e "${blue}************ RUNNING 01_patch_installconfig.sh ************${clear}" -/root/scripts/01_patch_installconfig.sh +echo -e "${blue}************ RUNNING 01_patch_config.sh ************${clear}" +/root/scripts/01_patch_config.sh echo -e "${blue}************ RUNNING 02_packages.sh ************${clear}" /root/scripts/02_packages.sh -MINOR=$(/root/bin/openshift-baremetal-install version | grep openshift-baremetal-install | cut -d' ' -f2 | cut -d. -f2) -if [ "$MINOR" -lt "10" ] ; then -echo -e "${blue}************ RUNNING 03_cache.sh ************${clear}" -/root/scripts/03_cache.sh -fi - {% if disconnected %} {% if disconnected_url == None %} -echo -e "${blue}************ RUNNING 04_disconnected_{{ 'quay.sh' if disconnected_quay else 'registry.sh' }}.sh ************${clear}" -/root/scripts/04_disconnected_{{ 'quay.sh' if disconnected_quay else 'registry.sh' }} || exit 1 +echo -e "${blue}************ RUNNING 03_disconnected_{{ 'quay.sh' if disconnected_quay else 'registry.sh' }}.sh ************${clear}" +/root/scripts/03_disconnected_{{ 'quay.sh' if disconnected_quay else 'registry.sh' }} || exit 1 {% endif %} -echo -e "${blue}************ RUNNING 04_disconnected_mirror.sh ************${clear}" -/root/scripts/04_disconnected_mirror.sh || exit 1 +echo -e "${blue}************ RUNNING 03_disconnected_mirror.sh ************${clear}" +/root/scripts/03_disconnected_mirror.sh || exit 1 {% if (disconnected_operators or disconnected_certified_operators or disconnected_community_operators or disconnected_marketplace_operators or disconnected_extra_catalogs) and not disconnected_operators_deploy_after_openshift %} -echo -e "${blue}************ RUNNING 04_disconnected_olm.sh ************${clear}" -/root/scripts/04_disconnected_olm.sh +echo -e "${blue}************ RUNNING 03_disconnected_olm.sh ************${clear}" +/root/scripts/03_disconnected_olm.sh {% if disconnected_url == None and disconnected_quay %} rm -rf /root/manifests-redhat-operator-index-* -/root/scripts/04_disconnected_olm.sh +/root/scripts/03_disconnected_olm.sh {% endif %} {% endif %} {% endif %} {% if nbde %} -echo -e "${blue}************ RUNNING 05_nbde.sh ************${clear}" -/root/scripts/05_nbde.sh +echo -e "${blue}************ RUNNING 04_nbde.sh ************${clear}" +/root/scripts/04_nbde.sh {% endif %} {% if ntp %} -echo -e "${blue}************ RUNNING 06_ntp.sh ************${clear}" -/root/scripts/06_ntp.sh +echo -e "${blue}************ RUNNING 05_ntp.sh ************${clear}" +/root/scripts/05_ntp.sh {% endif %} {% if deploy_openshift %} -echo -e "${blue}************ RUNNING 07_deploy_openshift.sh ************${clear}" +echo -e "${blue}************ RUNNING 06_deploy_openshift.sh ************${clear}" export KUBECONFIG=/root/ocp/auth/kubeconfig -/root/scripts/07_deploy_openshift.sh -sed -i "s/metal3-bootstrap/metal3/" /root/.bashrc -sed -i "s/172.22.0.2/172.22.0.3/" /root/.bashrc +/root/scripts/06_deploy_openshift.sh {% if nfs %} -echo -e "${blue}************ RUNNING 08_nfs.sh ************${clear}" -/root/scripts/08_nfs.sh +echo -e "${blue}************ RUNNING 07_nfs.sh ************${clear}" +/root/scripts/07_nfs.sh {% endif %} {% if imageregistry %} @@ -72,16 +64,16 @@ oc patch configs.imageregistry.operator.openshift.io cluster --type merge -p '{" {% endif %} {% if disconnected and (disconnected_operators or disconnected_certified_operators or disconnected_community_operators or disconnected_marketplace_operators or disconnected_extra_catalogs) and disconnected_operators_deploy_after_openshift %} -echo -e "${blue}************ RUNNING 04_disconnected_olm.sh ************${clear}" -/root/scripts/04_disconnected_olm.sh +echo -e "${blue}************ RUNNING 03_disconnected_olm.sh ************${clear}" +/root/scripts/03_disconnected_olm.sh {% endif %} -echo -e "${blue}************ RUNNING 09_post_install.sh ************${clear}" -/root/scripts/09_post_install.sh +echo -e "${blue}************ RUNNING 08_post_install.sh ************${clear}" +/root/scripts/08_post_install.sh {% if apps %} -echo -e "${blue}************ RUNNING 10_apps.sh ************${clear}" -/root/scripts/10_apps.sh +echo -e "${blue}************ RUNNING 09_apps.sh ************${clear}" +/root/scripts/09_apps.sh {% endif %} touch /root/cluster_ready.txt