Skip to content

Commit

Permalink
ansible: use rclone instead of aws CLI (#3945)
Browse files Browse the repository at this point in the history
Use rclone to upload assets to Cloudflare as it is more reliable.

Refs: #3508
  • Loading branch information
targos authored Nov 1, 2024
1 parent 648ff24 commit 8fc01e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 81 deletions.
45 changes: 0 additions & 45 deletions ansible/www-standalone/tasks/cloufdflare.yaml

This file was deleted.

16 changes: 3 additions & 13 deletions ansible/www-standalone/tools/promote/_resha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ if [ -z ${staging_bucket+x} ]; then
exit 1
fi

if [ -z ${cloudflare_endpoint+x} ]; then
echo "\$cloudflare_endpoint is not set"
exit 1
fi

if [ -z ${cloudflare_profile+x} ]; then
echo "\$cloudflare_profile is not set"
exit 1
fi

(cd "${dstdir}/${version}" && shasum -a256 $(ls node* openssl* iojs* win-*/* x64/* 2> /dev/null) > SHASUMS256.txt) || exit 1
if [[ $version =~ ^v[0] ]]; then
(cd "${dstdir}/${version}" && shasum $(ls node* openssl* x64/* 2> /dev/null) > SHASUMS.txt) || exit 1
Expand All @@ -54,6 +44,6 @@ find "${dstdir}/${version}" -type f -exec chmod 644 '{}' \;
find "${dstdir}/${version}" -type d -exec chmod 755 '{}' \;

relativedir=${dstdir/$dist_rootdir/"$site/"}
aws s3 cp ${dstdir}/index.json $staging_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null
aws s3 cp ${dstdir}/index.tab $staging_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null
aws s3 cp ${dstdir}/${version}/SHASUMS256.txt $staging_bucket/$relativedir/${version}/SHASUMS256.txt --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null
rclone copyto ${dstdir}/index.json $staging_bucket/$relativedir/index.json > /dev/null
rclone copyto ${dstdir}/index.tab $staging_bucket/$relativedir/index.tab > /dev/null
rclone copyto ${dstdir}/${version}/SHASUMS256.txt $staging_bucket/$relativedir/${version}/SHASUMS256.txt > /dev/null
6 changes: 2 additions & 4 deletions ansible/www-standalone/tools/promote/settings
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ chakracore_release_srcdir=${staging_rootdir}chakracore-release
chakracore_release_dstdir=${dist_rootdir}chakracore-release
chakracore_release_dirmatch=.*

cloudflare_endpoint=https://07be8d2fbc940503ca1be344714cb0d1.r2.cloudflarestorage.com
cloudflare_profile=worker
staging_bucket=s3://dist-staging
dist_bucket=s3://dist-prod
prod_bucket=r2:dist-prod
staging_bucket=r2:dist-staging
26 changes: 7 additions & 19 deletions ansible/www-standalone/tools/promote/upload_to_cloudflare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,18 @@ if [ -z ${dist_rootdir+x} ]; then
echo "\$dist_rootdir is not set"
exit 1
fi
if [ -z ${staging_bucket+x} ]; then
echo "\$staging_bucket is not set"
exit 1
fi
if [ -z ${dist_bucket+x} ]; then
echo "\$dist_bucket is not set"
if [ -z ${prod_bucket+x} ]; then
echo "\$prod_bucket is not set"
exit 1
fi
if [ -z ${cloudflare_endpoint+x} ]; then
echo "\$cloudflare_endpoint is not set"
exit 1
fi
if [ -z ${cloudflare_profile+x} ]; then
echo "\$cloudflare_profile is not set"
if [ -z ${staging_bucket+x} ]; then
echo "\$staging_bucket is not set"
exit 1
fi

relativedir=${dstdir/$dist_rootdir/"$site/"}
tmpversion=$2

# Due to R2 limitations, `aws s3 cp` and `aws s3 sync` only succeed in copying
# different sets of files across. Fortunately the sets are disjoint, so running
# both commands (ignoring errors) will copy all the files across.
aws s3 cp $staging_bucket/$relativedir/$tmpversion/ $dist_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --recursive --no-follow-symlinks --copy-props none || true
aws s3 sync $staging_bucket/$relativedir/$tmpversion/ $dist_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --no-follow-symlinks || true
aws s3 cp $staging_bucket/$relativedir/index.json $dist_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile
aws s3 cp $staging_bucket/$relativedir/index.tab $dist_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile
rclone copy $staging_bucket/$relativedir/$tmpversion/ $prod_bucket/$relativedir/$tmpversion/
rclone copyto $staging_bucket/$relativedir/index.json $prod_bucket/$relativedir/index.json
rclone copyto $staging_bucket/$relativedir/index.tab $prod_bucket/$relativedir/index.tab

0 comments on commit 8fc01e0

Please sign in to comment.