From df4d481f5c627e764532750eef1d1f62dd398043 Mon Sep 17 00:00:00 2001 From: James Gu Date: Tue, 6 Apr 2021 16:41:15 -0700 Subject: [PATCH] Deployment script enhancements Added 10 script to install required packaged and tools for a bew build node Fixed docker cmd permisson error in 21 script Fixed medadata path to use the SITE environment variable in 22 script Added abibility to configure nocheckout option in document pull Signed-off-by: James Gu Change-Id: Iea7c3e2cdac473188007e218f87889f6c1846bda --- tools/deployment/10_install_essentials.sh | 35 ++++++++++++++++++++ tools/deployment/21_systemwide_executable.sh | 10 +++--- tools/deployment/22_test_configs.sh | 4 +-- tools/deployment/23_pull_documents.sh | 8 ++++- 4 files changed, 49 insertions(+), 8 deletions(-) create mode 100755 tools/deployment/10_install_essentials.sh diff --git a/tools/deployment/10_install_essentials.sh b/tools/deployment/10_install_essentials.sh new file mode 100755 index 000000000..7b90a9993 --- /dev/null +++ b/tools/deployment/10_install_essentials.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# foo bar +set -xe + +install_pkg(){ + for i in "$@"; do + dpkg -l $i 2> /dev/null | grep ^ii > /dev/null || sudo DEBIAN_FRONTEND=noninteractive -E apt -y install $i + done +} + +if [ ! -f /var/lib/apt/periodic/update-success-stamp ] || \ + sudo find /var/lib/apt/periodic/update-success-stamp -mtime +1 | grep update-success-stamp; then + sudo -E apt -y update +fi + +install_pkg curl docker.io make + +./tools/deployment/provider_common/02_install_jq.sh +./tools/deployment/provider_common/03_install_pip.sh +./tools/deployment/provider_common/04_install_yq.sh +./tools/deployment/01_install_kubectl.sh +./tools/install_kustomize.sh diff --git a/tools/deployment/21_systemwide_executable.sh b/tools/deployment/21_systemwide_executable.sh index 4f06534c7..54ce4c1c4 100755 --- a/tools/deployment/21_systemwide_executable.sh +++ b/tools/deployment/21_systemwide_executable.sh @@ -21,13 +21,13 @@ export NO_PROXY=${NO_PROXY:-${no_proxy}} export PROXY=${PROXY:-${http_proxy}} echo "Build airshipctl docker images" -make images +sudo -E make images echo "Copy airshipctl from docker image" -DOCKER_IMAGE_TAG=$(make print-docker-image-tag) -CONTAINER=$(docker create "${DOCKER_IMAGE_TAG}") -sudo docker cp "${CONTAINER}:/usr/local/bin/airshipctl" "/usr/local/bin/airshipctl" -sudo docker rm "${CONTAINER}" +DOCKER_IMAGE_TAG=$(sudo -E make print-docker-image-tag) +CONTAINER=$(sudo -E docker create "${DOCKER_IMAGE_TAG}") +sudo -E docker cp "${CONTAINER}:/usr/local/bin/airshipctl" "/usr/local/bin/airshipctl" +sudo -E docker rm "${CONTAINER}" if ! airshipctl version | grep -q 'airshipctl'; then echo "Unable to verify airshipctl command. Please verify if the airshipctl is installed in /usr/local/bin/" diff --git a/tools/deployment/22_test_configs.sh b/tools/deployment/22_test_configs.sh index 02ceb574a..7872f95b5 100755 --- a/tools/deployment/22_test_configs.sh +++ b/tools/deployment/22_test_configs.sh @@ -30,7 +30,8 @@ export REMOTE_PROXY=false export AIRSHIP_CONFIG_ISO_SERVE_HOST=${HOST:-"localhost"} export AIRSHIP_CONFIG_ISO_PORT=${SERVE_PORT} export AIRSHIP_CONFIG_ISO_NAME=${ISO_NAME:-"ephemeral.iso"} -export AIRSHIP_CONFIG_METADATA_PATH=${AIRSHIP_CONFIG_METADATA_PATH:-"manifests/site/test-site/metadata.yaml"} +export SITE=${SITE:-"test-site"} +export AIRSHIP_CONFIG_METADATA_PATH=${AIRSHIP_CONFIG_METADATA_PATH:-"manifests/site/${SITE}/metadata.yaml"} export SYSTEM_ACTION_RETRIES=30 export SYSTEM_REBOOT_DELAY=30 export AIRSHIP_CONFIG_PHASE_REPO_BRANCH=${BRANCH:-"master"} @@ -38,7 +39,6 @@ export AIRSHIP_CONFIG_PHASE_REPO_BRANCH=${BRANCH:-"master"} export AIRSHIP_CONFIG_PHASE_REPO_URL=${AIRSHIP_CONFIG_PHASE_REPO_URL:-"https://review.opendev.org/airship/airshipctl"} export AIRSHIP_CONFIG_PHASE_REPO_NAME=${AIRSHIP_CONFIG_PHASE_REPO_NAME:-"airshipctl"} export AIRSHIP_CONFIG_MANIFEST_DIRECTORY=${AIRSHIP_CONFIG_MANIFEST_DIRECTORY:-"/tmp/airship"} -export SITE=${SITE:-"test-site"} export EXTERNAL_KUBECONFIG=${EXTERNAL_KUBECONFIG:-""} # Remove the contents of the .airship folder, preserving the kustomize plugin directory diff --git a/tools/deployment/23_pull_documents.sh b/tools/deployment/23_pull_documents.sh index 830d19ad1..9599222f8 100755 --- a/tools/deployment/23_pull_documents.sh +++ b/tools/deployment/23_pull_documents.sh @@ -14,5 +14,11 @@ set -xe +NO_CHECKOUT=${NO_CHECKOUT:-"true"} + echo "Pull site documents using airshipctl" -airshipctl document pull -n --debug +if [ ${NO_CHECKOUT} == "true" ]; then + airshipctl document pull -n --debug +else + airshipctl document pull --debug +fi