templates/packer: add failure script
In case the service failed, set the instance to unhealthy.
This commit is contained in:
parent
90dd99471c
commit
49566b7ce4
2 changed files with 11 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$SERVICE_RESULT" == "success" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Worker initialization failed, setting instance state to unhealthy"
|
||||
INSTANCE_ID=$(curl -Ls http://169.254.169.254/latest/meta-data/instance-id)
|
||||
/usr/local/bin/aws autoscaling set-instance-health --instance-id "$INSTANCE_ID" --health-status Unhealthy
|
||||
|
|
@ -21,6 +21,7 @@ ExecStart=/usr/local/libexec/worker-initialization-scripts/get_oci_creds.sh
|
|||
ExecStart=/usr/local/libexec/worker-initialization-scripts/get_pulp_creds.sh
|
||||
ExecStart=/usr/local/libexec/worker-initialization-scripts/get_ldap_sa_mtls_creds.sh
|
||||
ExecStart=/usr/local/libexec/worker-initialization-scripts/worker_service.sh
|
||||
ExecStopPost=/usr/local/libexec/worker-initialization-scripts/on_exit.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue