From 917544546fd09faeb43497d20afcc83900aeb3ed Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 22 Jun 2021 09:33:56 +1000 Subject: [PATCH] centos-mirror: add dry run mode Add a dry-run flag and abstract the rsync command to make for easier testing if modifying the copy flags. Change-Id: Ie658b60257b94436b1eda0cddf6deb639a87d659 --- .../mirror-update/files/centos-mirror-update | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/playbooks/roles/mirror-update/files/centos-mirror-update b/playbooks/roles/mirror-update/files/centos-mirror-update index 2f11ad87ce..519017b33c 100755 --- a/playbooks/roles/mirror-update/files/centos-mirror-update +++ b/playbooks/roles/mirror-update/files/centos-mirror-update @@ -24,6 +24,14 @@ else TIMEOUT="timeout -k 2m 30m" fi +_DRY_RUN='' +if [[ ${DRY_RUN:-0} -eq 1 ]]; then + echo "Dry run only" + _DRY_RUN='--dry-run' +fi + +RSYNC="rsync ${_DRY_RUN} -rltvz" + BASE="/afs/.openstack.org/mirror/centos" K5START="k5start -t -f /etc/centos.keytab service/centos-mirror -- $TIMEOUT" @@ -38,7 +46,7 @@ if ! [ -f $BASE/8-stream ]; then fi date --iso-8601=ns echo "Running Centos 8-stream rsync..." -$K5START rsync -rltvz \ +$K5START ${RSYNC} \ --delete \ --delete-excluded \ --exclude="isos" \ @@ -56,7 +64,7 @@ if ! [ -f $BASE/8 ]; then fi date --iso-8601=ns echo "Running Centos 8 rsync..." -$K5START rsync -rltvz \ +$K5START ${RSYNC} \ --delete \ --delete-excluded \ --exclude="isos" \ @@ -94,7 +102,7 @@ for REPO in $REPOS; do date --iso-8601=ns echo "Running rsync..." - $K5START rsync -rltvz \ + $K5START ${RSYNC} \ --delete \ --delete-excluded \ --exclude="atomic" \ @@ -110,9 +118,11 @@ for REPO in $REPOS; do # TODO(pabelanger): Validate rsync process done -date --iso-8601=ns | $K5START tee $BASE/timestamp.txt -echo "rsync completed successfully, running vos release." -vos_release $MIRROR_VOLUME +if [[ ${DRY_RUN:-0} -ne 1 ]]; then + date --iso-8601=ns | $K5START tee $BASE/timestamp.txt + echo "rsync completed successfully, running vos release." + vos_release $MIRROR_VOLUME +fi date --iso-8601=ns echo "Done."