Merge "Add script to refresh deploy plug-in post patching"

This commit is contained in:
Zuul 2023-07-21 13:18:27 +00:00 committed by Gerrit Code Review
commit 40e18a57eb
4 changed files with 55 additions and 1 deletions
utilities/platform-util

@ -4,6 +4,7 @@ scripts/show-certs.sh usr/local/bin
scripts/stx-iso-utils.sh usr/local/bin
scripts/stx-iso-utils-centos.sh usr/local/bin
scripts/update-iso.sh usr/local/bin
scripts/update-dm.sh usr/local/bin
scripts/update_docker_registry_auth.sh usr/local/bin
scripts/change_system_private_registry.sh usr/local/bin
scripts/local_starlingxrc usr/local/bin

@ -4,6 +4,7 @@
/usr/local/bin/stx-iso-utils.sh
/usr/local/bin/stx-iso-utils-centos.sh
/usr/local/bin/update-iso.sh
/usr/local/bin/update-dm.sh
/usr/local/bin/update_docker_registry_auth.sh
/usr/local/bin/change_system_private_registry.sh
/usr/local/bin/local_starlingxrc

@ -30,6 +30,7 @@ override_dh_auto_install:
install -d $(DEBIAN_BUILDDIR)/usr/local/bin/
install -m 555 scripts/update-iso.sh $(DEBIAN_BUILDDIR)/usr/local/bin/
install -m 555 scripts/update-dm.sh $(DEBIAN_BUILDDIR)/usr/local/bin/
install -m 555 scripts/gen-bootloader-iso.sh $(DEBIAN_BUILDDIR)/usr/local/bin/
install -m 555 scripts/gen-bootloader-iso-centos.sh $(DEBIAN_BUILDDIR)/usr/local/bin/
install -m 555 scripts/stx-iso-utils.sh $(DEBIAN_BUILDDIR)/usr/local/bin/
@ -50,7 +51,7 @@ override_dh_auto_install:
dh_install
override_dh_fixperms:
dh_fixperms -Xupdate-iso.sh -Xgen-bootloader-iso.sh -Xstx-iso-utils.sh \
dh_fixperms -Xupdate-iso.sh -Xpatch-dm.sh -Xgen-bootloader-iso.sh -Xstx-iso-utils.sh \
-Xshow-certs.sh -Xupdate_docker_registry_auth.sh -Xchange_system_private_registry.sh \
-Xis-rootdisk-device.sh -Xlocal_starlingxrc -Xpatch-restart-* -Xconnectivity_test \
-Xset_keystone_user_option.sh

@ -0,0 +1,51 @@
#!/bin/bash
#
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script automates deploy plug-in update to
# 1. run ansible playbook to upgrade static images
# - pull image from configured source
# - push image to local registry
# 2. run ansible playbook to refresh deploy plug-in
#
export KUBECONFIG=/etc/kubernetes/admin.conf
UPGRADE_STATIC_IMAGE_PLAYBOOK=/usr/share/ansible/stx-ansible/playbooks/upgrade-static-images.yml
DEPLOY_OVERRIDES=$1
DEPLOY_CHART=$2
DEPLOY_PLAYBOOK=$3
# This will log to /var/log/platform.log
function log {
logger -p local1.info $1
}
# Step-1
log "Run upgrade-static-images playbook to pull image from remote registry & push to local registry"
K8S_VERSION=$(kubectl get nodes|tail -1|awk '{print $5}')
ansible-playbook -e "kubernetes_version=${K8S_VERSION}" $UPGRADE_STATIC_IMAGE_PLAYBOOK
RC=$?
if [ $RC -eq 0 ]; then
log "The upgrade static image playbook was executed successfully"
else
log "The upgrade static image playbook failed with error: $RC"
exit $RC
fi
# Step-2
log "Run ansible playbook to refresh deploy plug-in"
ansible-playbook -e "deployment_manager_overrides=$DEPLOY_OVERRIDES deployment_manager_chart=$DEPLOY_CHART" $DEPLOY_PLAYBOOK
RC=$?
if [ $RC -eq 0 ]; then
log "The deployment playbook was executed successfully"
else
log "The deployment playbook failed with error: $RC"
exit $RC
fi
exit 0