DEV-298: added hacky shell script to make harbor upgrade a little bit easier

master
Görz, Friedrich 4 years ago committed by Ketelsen, Sven
parent 5bc712b4f2
commit 34a88236f3

@ -1,3 +1,3 @@
--- ---
harbor_version: v2.3.0 harbor_version: v2.4.1

@ -30,6 +30,16 @@
tags: tags:
- update_config - update_config
- name: 'Copy hacky upgrade script'
template:
src: 'hacky_harbor_upgrade.sh.j2'
dest: '/root/hacky_harbor_upgrade.sh'
owner: 'root'
group: 'root'
mode: '0744'
tags:
- upgrade-helper
- name: Ensure config template files are populated from templates/harbor - name: Ensure config template files are populated from templates/harbor
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"

@ -0,0 +1,46 @@
#!/bin/bash
#
#
#
# plz be careful when comment exit-statement!!!!
exit
NEW_HARBOR_VERSION='v2.4.1'
DOWNLOAD_DEST_DIR='/tmp'
DOWNLOAD_DEST_FILE="${DOWNLOAD_DEST_DIR}/harbor-online-installer-${NEW_HARBOR_VERSION}.tgz"
SMARDIGO_HOME="{{ service_base_path }}/{{ inventory_hostname }}"
HARBOR_BACKUP_DIR="/opt/harbor_bkp_dir"
echo "downloading trabll with new harbor version"
wget https://github.com/goharbor/harbor/releases/download/${NEW_HARBOR_VERSION}/harbor-online-installer-${NEW_HARBOR_VERSION}.tgz -O ${DOWNLOAD_DEST_FILE}
echo "docker pull harbor-migration image"
docker pull goharbor/prepare:${NEW_HARBOR_VERSION}
echo "Stopping harbor..."
cd ${SMARDIGO_HOME}/harbor
docker-compose down
if [ ! -d ${HARBOR_BACKUP_DIR} ]; then
echo "saving old install dir + pg-data-dir"
cd ${SMARDIGO_HOME}
mkdir -p ${HARBOR_BACKUP_DIR}
mv "${SMARDIGO_HOME}/harbor" ${HARBOR_BACKUP_DIR}/
cp -r /data/database ${HARBOR_BACKUP_DIR}/
else
echo "backup dir << ${HARBOR_BACKUP_DIR} >> for old harbor installtion detected. ply removed before proceeding"
exit
fi
echo "unpacking tarball new harbor version..."
tar -xzf ${DOWNLOAD_DEST_FILE} -C ${SMARDIGO_HOME}
echo "copy harbor.yml for upgrade-prepare step"
cp ${HARBOR_BACKUP_DIR}/harbor/harbor.yml ${SMARDIGO_HOME}/harbor/harbor.yml
echo "running docker container for harbor-migration to version: $NEW_HARBOR_VERSION ..."
docker run -it --rm -v /:/hostfs goharbor/prepare:${NEW_HARBOR_VERSION} migrate -i ${SMARDIGO_HOME}/harbor/harbor.yml
echo "starting harbor installation ..."
${SMARDIGO_HOME}/harbor/install.sh --with-trivy --with-chartmuseum

@ -33,7 +33,7 @@
state: present state: present
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
retries: 5 retries: 15
delay: 10 delay: 10
tags: tags:
- update_networks - update_networks

Loading…
Cancel
Save