forked from openshift/osd-network-verifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserdata.yaml
More file actions
31 lines (31 loc) · 1.82 KB
/
userdata.yaml
File metadata and controls
31 lines (31 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#cloud-config
repo_update: true
write_files:
- path: /run-container.sh
permissions: 755
content: |
#!/bin/bash
echo "${USERDATA_BEGIN}" >> /var/log/userdata-output
# Look for the image pre-pulled in the AMI, if not available, try to pull it
IMAGE=`docker images ${VALIDATOR_REPO} -q | head -n 2 | tail -n 1`
if [[ -z "${IMAGE}" ]]; then
sudo docker pull ${VALIDATOR_IMAGE} >> /var/log/userdata-output
IMAGE=`docker images ${VALIDATOR_REPO} -q | head -n 2 | tail -n 1`
fi
echo "Using IMAGE: $IMAGE" >> /var/log/userdata-output
if [[ "${CACERT}" != "" ]]; then
echo "${CACERT}" | base64 --decode > /proxy.pem
sudo docker run -v /proxy.pem:/proxy.pem:Z -e "HTTP_PROXY=${HTTP_PROXY}" -e "HTTPS_PROXY=${HTTPS_PROXY}" -e "AWS_REGION=${AWS_REGION}" -e "START_VERIFIER=${VALIDATOR_START_VERIFIER}" -e "END_VERIFIER=${VALIDATOR_END_VERIFIER}" ${IMAGE} --timeout=${TIMEOUT} --config=${CONFIG_PATH} --cacert=/proxy.pem --no-tls=${NOTLS} >> /var/log/userdata-output || echo "Failed to successfully run the docker container"
else
sudo docker run -e "AWS_REGION=${AWS_REGION}" -e "HTTP_PROXY=${HTTP_PROXY}" -e "HTTPS_PROXY=${HTTPS_PROXY}" -e "START_VERIFIER=${VALIDATOR_START_VERIFIER}" -e "END_VERIFIER=${VALIDATOR_END_VERIFIER}" ${IMAGE} --timeout=${TIMEOUT} --config=${CONFIG_PATH} >> /var/log/userdata-output || echo "Failed to successfully run the docker container"
fi
echo "${USERDATA_END}" >> /var/log/userdata-output
runcmd:
- sudo systemctl start docker 2>1 > /dev/null || echo "docker not started by systemctl"
- HTTP_PROXY=${HTTP_PROXY} HTTPS_PROXY=${HTTPS_PROXY} /run-container.sh
- cat /var/log/userdata-output >/dev/console
power_state:
delay: ${DELAY}
mode: poweroff
message: Auto-terminating instance due to timeout
timeout: 300