@@ -1,6 +1,7 @@ | |||||
{ | { | ||||
"name": "finalizer", | "name": "finalizer", | ||||
"config": [ | "config": [ | ||||
{"name": "server_name", "value": "[[node.fqdn]]"}, | |||||
{"name": "server_alias", "value": "[[network.networkDomain]]"}, | {"name": "server_alias", "value": "[[network.networkDomain]]"}, | ||||
{"name": "restore_key", "value": "[[restoreKey]]"}, | {"name": "restore_key", "value": "[[restoreKey]]"}, | ||||
{"name": "install_type", "value": "[[installType]]"}, | {"name": "install_type", "value": "[[installType]]"}, | ||||
@@ -42,9 +42,12 @@ | |||||
- name: reload supervisord | - name: reload supervisord | ||||
shell: supervisorctl reload | shell: supervisorctl reload | ||||
# dhparams file is created async. it takes a while and might not have finished. nginx will fail to start without it. | |||||
- name: Ensure dhparams.pem exists | |||||
shell: /usr/local/bin/ensure_file_exists.sh /etc/nginx/dhparams.pem 300 | |||||
- name: Ensure nginx required files exist | |||||
shell: /usr/local/bin/ensure_file_exists.sh {{ item }} 300 | |||||
with_items: | |||||
- /etc/nginx/dhparams.pem | |||||
- /etc/letsencrypt/live/{{ server_alias }}/fullchain.pem | |||||
- /etc/letsencrypt/live/{{ server_name }}/fullchain.pem | |||||
- name: Ensure nginx is restarted | - name: Ensure nginx is restarted | ||||
service: | service: | ||||
@@ -7,13 +7,15 @@ TIMEOUT=${2:?no timeout provided} | |||||
LOG=/tmp/ensure_file_$(echo ${TARGET_FILE} | tr '/' '_').log | LOG=/tmp/ensure_file_$(echo ${TARGET_FILE} | tr '/' '_').log | ||||
start=$(date +%s) | start=$(date +%s) | ||||
while [[ ! -f ${TARGET_FILE} && $(expr $(date +%s) - ${start}) -le ${TIMEOUT} ]] ; do | |||||
echo "$(date): $0: waiting for target file to exist ${TARGET_FILE} (will timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} | |||||
while [[ ! -s ${TARGET_FILE} && $(expr $(date +%s) - ${start}) -le ${TIMEOUT} ]] ; do | |||||
echo "$(date): $0: waiting for target file to exist with some content ${TARGET_FILE} (will timeout after ${TIMEOUT} seconds)" \ | |||||
| tee -a ${LOG} | |||||
sleep 1s | sleep 1s | ||||
done | done | ||||
if [[ ! -f ${TARGET_FILE} ]] ; then | |||||
echo "target file did not get created: ${TARGET_FILE} (timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} | |||||
if [[ ! -s ${TARGET_FILE} ]] ; then | |||||
echo "target file did not get created or is empty: ${TARGET_FILE} (timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
echo "target file has been created: ${TARGET_FILE}" | tee -a ${LOG} | |||||
echo "target file has been created: ${TARGET_FILE}" | tee -a ${LOG} |