diff --git a/infrastructure/deployment/deploy.sh b/infrastructure/deployment/deploy.sh index 8e63b18f..0eb252e3 100755 --- a/infrastructure/deployment/deploy.sh +++ b/infrastructure/deployment/deploy.sh @@ -208,12 +208,12 @@ generate_password() { to_remote_paths() { paths=$@ - echo "$paths" | sed "s|/tmp/|/opt/opencrvs/infrastructure/|g" | sed "s|$INFRASTRUCTURE_DIRECTORY/docker-compose|/opt/opencrvs/infrastructure/docker-compose|g" + echo "$paths" | sed "s|/tmp/|/opt/opencrvs/$STACK/infrastructure/|g" | sed "s|$INFRASTRUCTURE_DIRECTORY/docker-compose|/opt/opencrvs/$STACK/infrastructure/docker-compose|g" } rotate_secrets() { files_to_rotate=$(to_remote_paths $COMPOSE_FILES_USED) - configured_ssh '/opt/opencrvs/infrastructure/rotate-secrets.sh '$files_to_rotate' | tee -a '$LOG_LOCATION'/rotate-secrets.log' + configured_ssh '/opt/opencrvs/$STACK/infrastructure/rotate-secrets.sh '$files_to_rotate' | tee -a '$LOG_LOCATION'/rotate-secrets.log' } @@ -412,14 +412,15 @@ echo "Deploying COUNTRY_CONFIG_VERSION $COUNTRY_CONFIG_VERSION to $SSH_HOST..." echo echo "Syncing configuration files to the target server" -configured_rsync -rlD $PROJECT_ROOT/infrastructure $SSH_USER@$SSH_HOST:/opt/opencrvs/ --delete --no-perms --omit-dir-times --verbose +configured_rsync -rlD $PROJECT_ROOT/infrastructure $SSH_USER@$SSH_HOST:/opt/opencrvs/$STACK --delete --no-perms --omit-dir-times --verbose echo "Logging to Dockerhub" configured_ssh "docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN" + # Setup configuration files and compose file for the deployment domain -configured_ssh "/opt/opencrvs/infrastructure/setup-deploy-config.sh $HOST" +configured_ssh "/opt/opencrvs/$STACK/infrastructure/setup-deploy-config.sh $HOST $STACK" rotate_secrets @@ -436,7 +437,7 @@ if [ "$UPDATE_DEPENDENCIES" = true ]; then echo 'Setting up elastalert indices' while true; do - if configured_ssh "/opt/opencrvs/infrastructure/elasticsearch/setup-elastalert-indices.sh"; then + if configured_ssh "/opt/opencrvs/$STACK/infrastructure/elasticsearch/setup-elastalert-indices.sh"; then break fi sleep 5 @@ -445,7 +446,7 @@ if [ "$UPDATE_DEPENDENCIES" = true ]; then echo "Setting up Kibana config & alerts" while true; do - if configured_ssh "HOST=kibana.$HOST /opt/opencrvs/infrastructure/monitoring/kibana/setup-config.sh"; then + if configured_ssh "HOST=kibana.$HOST /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/setup-config.sh"; then break fi sleep 5 @@ -454,7 +455,7 @@ else echo 'Waiting for Elasticsearch to be ready' while true; do - if configured_ssh "/opt/opencrvs/infrastructure/elasticsearch/wait-for-elasticsearch.sh"; then + if configured_ssh "/opt/opencrvs/$STACK/infrastructure/elasticsearch/wait-for-elasticsearch.sh"; then break fi sleep 5 diff --git a/infrastructure/monitoring/kibana/setup-config.sh b/infrastructure/monitoring/kibana/setup-config.sh index 6183f929..22c832a6 100755 --- a/infrastructure/monitoring/kibana/setup-config.sh +++ b/infrastructure/monitoring/kibana/setup-config.sh @@ -26,7 +26,7 @@ response_text_from_curl_output() { } curl_raw() { - docker run --rm -v /opt/opencrvs/infrastructure/monitoring/kibana/config.ndjson:/config.ndjson --network=dependencies_elasticsearch_net curlimages/curl -s -w "\n%{http_code}" "$@" + docker run --rm -v /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/config.ndjson:/config.ndjson --network=dependencies_elasticsearch_net curlimages/curl -s -w "\n%{http_code}" "$@" } parse_url_from_string() { diff --git a/infrastructure/setup-deploy-config.sh b/infrastructure/setup-deploy-config.sh index f1d0a0f6..354511ee 100755 --- a/infrastructure/setup-deploy-config.sh +++ b/infrastructure/setup-deploy-config.sh @@ -10,20 +10,20 @@ set -e echo HOST=$1 - +STACK=$2 echo "Setting up deployment config for $HOST - `date --iso-8601=ns`" # Set hostname in compose file -for file in /opt/opencrvs/infrastructure/docker-compose*.yml; do +for file in /opt/opencrvs/$STACK/infrastructure/docker-compose*.yml; do sed -i "s/{{hostname}}/$HOST/g" "$file" done # Setup an encryption key for Kibana KIBANA_ENCRYPTION_KEY=`uuidgen` -sed -i "s/{{KIBANA_ENCRYPTION_KEY}}/$KIBANA_ENCRYPTION_KEY/g" /opt/opencrvs/infrastructure/monitoring/kibana/kibana.yml +sed -i "s/{{KIBANA_ENCRYPTION_KEY}}/$KIBANA_ENCRYPTION_KEY/g" /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/kibana.yml -sed -i -e "s%{{MINIO_ROOT_USER}}%$MINIO_ROOT_USER%" /opt/opencrvs/infrastructure/mc-config/config.json -sed -i -e "s%{{MINIO_ROOT_PASSWORD}}%$MINIO_ROOT_PASSWORD%" /opt/opencrvs/infrastructure/mc-config/config.json +sed -i -e "s%{{MINIO_ROOT_USER}}%$MINIO_ROOT_USER%" /opt/opencrvs/$STACK/infrastructure/mc-config/config.json +sed -i -e "s%{{MINIO_ROOT_PASSWORD}}%$MINIO_ROOT_PASSWORD%" /opt/opencrvs/$STACK/infrastructure/mc-config/config.json echo "DONE - `date --iso-8601=ns`" echo