-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-init.yml
More file actions
64 lines (47 loc) · 1.67 KB
/
cloud-init.yml
File metadata and controls
64 lines (47 loc) · 1.67 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#cloud-config
package_update: true
package_upgrade: true
packages:
- curl
- ca-certificates
- git
- python3
- python3-venv
- nodejs
- npm
- apt-transport-https
- jq
write_files:
- path: /opt/bootstrap/bootstrap.sh
permissions: "0755"
content: |
#!/usr/bin/env bash
set -euo pipefail
LOG_BOOTSTRAP="/var/log/bootstrap.log"
TARGET="raw.githubusercontent.com"
# Loop until DNS resolves
while ! getent hosts "$TARGET" >/dev/null 2>&1; do
echo "[bootstrap] DNS not ready yet. Retrying... $(date -Is)" | tee -a "$LOG_BOOTSTRAP"
sleep 30
done
ZIP_URL="https://aka.ms/XDROpsLabLinux"
echo "[bootstrap] Downloading installer package from $ZIP_URL" | tee -a "$LOG_BOOTSTRAP"
mkdir -p /opt/bootstrap
curl -fsSL "$ZIP_URL" -o /opt/bootstrap/XDROps.tar.gz
tar -xzf /opt/bootstrap/XDROps.tar.gz -C /opt/bootstrap
# --- Determine hostname ---
HOSTNAME_MATCH=$(hostname)
echo "[bootstrap] System hostname: $HOSTNAME_MATCH" | tee -a "$LOG_BOOTSTRAP"
# --- Look for a matching file ---
MATCHING_FILE="/opt/bootstrap/$HOSTNAME_MATCH.sh"
if [[ -f "$MATCHING_FILE" ]]; then
echo "[bootstrap] Found matching file: $MATCHING_FILE" | tee -a "$LOG_BOOTSTRAP"
chmod +x "$MATCHING_FILE"
echo "Running $MATCHING_FILE..."
"$MATCHING_FILE"
else
echo "[bootstrap] No file matching hostname found." | tee -a "$LOG_BOOTSTRAP"
fi
echo "[bootstrap] Completed." | tee -a "$LOG_BOOTSTRAP"
runcmd:
- [ bash, -lc, "/opt/bootstrap/bootstrap.sh" ]