From 6f9b837609b69333f463dbb21e0ab89ac3051116 Mon Sep 17 00:00:00 2001 From: Huy Mai Date: Tue, 13 Aug 2024 06:35:40 +0000 Subject: [PATCH] Take Deploy-cli into use to replace deploy.sh Now that we have deploy-cli in BMO main, we can start using it to replace deploy.sh in installing BMO and Ironic. Signed-off-by: Huy Mai --- 02_configure_host.sh | 10 ++++++++++ 03_launch_mgmt_cluster.sh | 12 +++++++----- lib/common.sh | 7 ++++++- tests/roles/run_tests/tasks/move.yml | 6 ++++-- tests/roles/run_tests/tasks/move_back.yml | 6 ++++-- tests/roles/run_tests/vars/main.yml | 5 ++++- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/02_configure_host.sh b/02_configure_host.sh index 64156c1bf..ef7c98b86 100755 --- a/02_configure_host.sh +++ b/02_configure_host.sh @@ -312,6 +312,16 @@ mkdir -p "${M3PATH}" detect_mismatch "${BMO_LOCAL_IMAGE:-}" "${BMOPATH}" clone_repo "${BMOREPO}" "${BMOBRANCH}" "${BMOPATH}" "${BMOCOMMIT}" +export DEPLOY_TOOL="${BMOPATH}/tools/deploy.sh" +if [[ "${BMOBRANCH}" = "main" ]] || [[ "${BMOBRANCH}" = "release-0.9" ]]; then + # Install deploy-cli. + pushd "${BMOPATH}" + make deploy-cli + sudo install tools/bin/deploy-cli /usr/bin/ + export DEPLOY_TOOL="deploy-cli" + popd +fi + detect_mismatch "${CAPM3_LOCAL_IMAGE:-}" "${CAPM3PATH}" clone_repo "${CAPM3REPO}" "${CAPM3BRANCH}" "${CAPM3PATH}" "${CAPM3COMMIT}" diff --git a/03_launch_mgmt_cluster.sh b/03_launch_mgmt_cluster.sh index 44743a9af..9328572c4 100755 --- a/03_launch_mgmt_cluster.sh +++ b/03_launch_mgmt_cluster.sh @@ -51,7 +51,7 @@ launch_baremetal_operator() { pushd "${BMOPATH}" - # Deploy BMO using deploy.sh script + # Deploy BMO using DEPLOY_TOOL if [[ "${EPHEMERAL_CLUSTER}" != "tilt" ]]; then # Update container images to use local ones if [[ -n "${BARE_METAL_OPERATOR_LOCAL_IMAGE:-}" ]]; then @@ -78,8 +78,9 @@ EOF echo "DEPLOY_ISO_URL=${DEPLOY_ISO_URL}" | sudo tee -a "${BMOPATH}/config/default/ironic.env" fi - # Deploy BMO using deploy.sh script - "${BMOPATH}/tools/deploy.sh" -b "${BMO_IRONIC_ARGS[@]}" + # Deploy BMO using DEPLOY_TOOL + export BMOPATH + "${DEPLOY_TOOL}" -b "${BMO_IRONIC_ARGS[@]}" # If BMO should run locally, scale down the deployment and run BMO if [[ "${BMO_RUN_LOCAL}" = "true" ]]; then @@ -236,8 +237,9 @@ EOF echo "Waiting for Ironic to become ready" retry sudo "${CONTAINER_RUNTIME}" exec ironic /bin/ironic-readiness else - # Deploy Ironic using deploy.sh script - "${BMOPATH}/tools/deploy.sh" -i "${BMO_IRONIC_ARGS[@]}" + # Deploy Ironic using DEPLOY_TOOL + export BMOPATH + "${DEPLOY_TOOL}" -i "${BMO_IRONIC_ARGS[@]}" fi popd } diff --git a/lib/common.sh b/lib/common.sh index 0eeaa20b3..f86135d83 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -280,6 +280,12 @@ export SUSHY_TOOLS_IMAGE="${SUSHY_TOOLS_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/s export FAKE_IPA_IMAGE="${FAKE_IPA_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/fake-ipa}" export FKAS_IMAGE="${FKAS_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/metal3-fkas}" +# Default Deploy tool is set to deploy-cli. We will still use the old deploy.sh script for release-1.8 and earlier. +export DEPLOY_TOOL="deploy-cli" +if [[ "${CAPM3RELEASEBRANCH}" =~ release-1.(8|6|5) ]]; then + export DEPLOY_TOOL="${BMOPATH}/tools/deploy.sh" +fi + # CAPM3 and IPAM controller images if [[ "${CAPM3RELEASEBRANCH}" = "release-1.6" ]]; then export CAPM3_IMAGE=${CAPM3_IMAGE:-"${CONTAINER_REGISTRY}/metal3-io/cluster-api-provider-metal3:release-1.6"} @@ -336,7 +342,6 @@ export IPXE_SOURCE_DIR="${IRONIC_DATA_DIR}/ipxe-source" export IRONIC_KEEPALIVED_IMAGE="${IRONIC_KEEPALIVED_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/keepalived:${KEEPALIVED_TAG}}" export MARIADB_IMAGE="${MARIADB_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/mariadb:${MARIADB_TAG}}" - # Enable ironic restart feature when the TLS certificate is updated export RESTART_CONTAINER_CERTIFICATE_UPDATED="${RESTART_CONTAINER_CERTIFICATE_UPDATED:-${IRONIC_TLS_SETUP}}" diff --git a/tests/roles/run_tests/tasks/move.yml b/tests/roles/run_tests/tasks/move.yml index ad3d78dca..eb2d8932b 100644 --- a/tests/roles/run_tests/tasks/move.yml +++ b/tests/roles/run_tests/tasks/move.yml @@ -114,21 +114,23 @@ # Install BMO - name: Install Baremetal Operator - shell: "{{ BMOPATH }}/tools/deploy.sh -b {{ BMO_IRONIC_ARGS }}" + shell: "{{ DEPLOY_TOOL }} -b {{ BMO_IRONIC_ARGS }}" environment: IRONIC_HOST: "{{ IRONIC_HOST }}" IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}" KUBECTL_ARGS: "{{ KUBECTL_ARGS }}" + BMOPATH: "{{ BMOPATH }}" args: chdir: "{{ BMOPATH }}" # Install Ironic - name: Install Ironic - shell: "{{ BMOPATH }}/tools/deploy.sh -i {{ BMO_IRONIC_ARGS }}" + shell: "{{ DEPLOY_TOOL }} -i {{ BMO_IRONIC_ARGS }}" environment: IRONIC_HOST: "{{ IRONIC_HOST }}" IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}" KUBECTL_ARGS: "{{ KUBECTL_ARGS }}" + BMOPATH: "{{ BMOPATH }}" args: chdir: "{{ BMOPATH }}" diff --git a/tests/roles/run_tests/tasks/move_back.yml b/tests/roles/run_tests/tasks/move_back.yml index 947544532..1142c1673 100644 --- a/tests/roles/run_tests/tasks/move_back.yml +++ b/tests/roles/run_tests/tasks/move_back.yml @@ -11,10 +11,11 @@ # Install BMO in Source cluster - name: Install Baremetal Operator in Source cluster - shell: "{{ BMOPATH }}/tools/deploy.sh -b {{ BMO_IRONIC_ARGS }}" + shell: "{{ DEPLOY_TOOL }} -b {{ BMO_IRONIC_ARGS }}" environment: IRONIC_HOST: "{{ IRONIC_HOST }}" IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}" + BMOPATH: "{{ BMOPATH }}" args: chdir: "{{ BMOPATH }}" @@ -25,10 +26,11 @@ when: EPHEMERAL_CLUSTER == "kind" - name: Install Ironic in Source cluster (Ephemeral Cluster is minikube) - shell: "{{ BMOPATH }}/tools/deploy.sh -i {{ BMO_IRONIC_ARGS }}" + shell: "{{ DEPLOY_TOOL }} -i {{ BMO_IRONIC_ARGS }}" environment: IRONIC_HOST: "{{ IRONIC_HOST }}" IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}" + BMOPATH: "{{ BMOPATH }}" when: EPHEMERAL_CLUSTER == "minikube" args: chdir: "{{ BMOPATH }}" diff --git a/tests/roles/run_tests/vars/main.yml b/tests/roles/run_tests/vars/main.yml index 27e84296c..6a7e5f480 100644 --- a/tests/roles/run_tests/vars/main.yml +++ b/tests/roles/run_tests/vars/main.yml @@ -92,7 +92,10 @@ CAPM3_INSECURE_DIAGNOSTICS: "true" IPAM_DIAGNOSTICS_ADDRESS: "localhost:8080" IPAM_INSECURE_DIAGNOSTICS: "true" -# Args to pass to the deploy.sh script when deploying Ironic and BMO +# DEPLOY_TOOL for deploying Ironic and BMO +DEPLOY_TOOL: "{{ lookup('env', 'DEPLOY_TOOL') }}" + +# Args to pass to the DEPLOY_TOOL when deploying Ironic and BMO # [k]eepalived [t]ls [n]o basic auth or [m]ariadb BMO_IRONIC_ARGS: "-k {{ (IRONIC_TLS_SETUP == 'true') | ternary('-t', '') }} {{ (IRONIC_BASIC_AUTH == 'true') | ternary('', '-n') }} {{ (IRONIC_USE_MARIADB == 'true') | ternary('-m', '') }}"