openstack-ansible-repo_server/templates/repo_prepost_cmd.sh.j2
Georgina 7132acbd3b Allow remote detection of repo sync status
If a repo container and its data are deleted and recreated then it is
not currently possible for a loadbalancer healthcheck to differentiate
between an empty repo server and a correctly synchronised one.

This patch creates a file 'repo-sync-complete' as part of the process
of synchronising repo contents from master repo servers to slaves. The
presence of this file on the slave can then be used as the loadbalancer
healthcheck to ensure that repo contents are only served once sync has
completed.

In addition, this patch ensures that synchronisation occurs from the
master to a reprovisioned slave by triggering a master repo server lsyncd
restart handler during the initial setup of the slave repo server.
Currently, a freshly provisioned repo server will remain empty
for an indeterminate amount of time, this patch forces a complete re-sync
to occur.

Change-Id: I6913341674dbde5524c2270e824bda4544211eca
2020-10-27 13:37:21 +02:00

19 lines
511 B
Django/Jinja

#!/bin/bash
# This script is called by lsyncd to perform 'pre' and 'post' rsync tasks.
#
CMD=$1
case $CMD in
pre-www)
rm /etc/nginx/sites-enabled/openstack-slushee.vhost
systemctl reload nginx
rm -f {{ repo_service_home_folder }}/repo/repo_sync_complete
;;
post-www)
ln -s /etc/nginx/sites-available/openstack-slushee.vhost /etc/nginx/sites-enabled/openstack-slushee.vhost
systemctl reload nginx
touch {{ repo_service_home_folder }}/repo/repo_sync_complete
;;
*)
echo "Unknown command."
esac