feat: add cloud-init Go parser (Phase 2)
Implement a lightweight cloud-init system for first-boot configuration: - Go parser for YAML config (hostname, network, KubeSolo settings) - Static/DHCP network modes with DNS override - KubeSolo extra flags and API server SAN configuration - Portainer Edge Agent and air-gapped deployment support - New init stage 45-cloud-init.sh runs before network/hostname stages - Stages 50/60 skip gracefully when cloud-init has already applied - Build script compiles static Linux/amd64 binary (~2.7 MB) - 17 unit tests covering parsing, validation, and example files - Full documentation at docs/cloud-init.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
35
init/lib/45-cloud-init.sh
Normal file
35
init/lib/45-cloud-init.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# 45-cloud-init.sh — Apply cloud-init configuration
|
||||
#
|
||||
# Runs the kubesolo-cloudinit binary to parse cloud-init.yaml and apply:
|
||||
# - hostname (/etc/hostname, /etc/hosts)
|
||||
# - network (static IP or DHCP)
|
||||
# - KubeSolo settings (/etc/kubesolo/extra-flags, config.yaml)
|
||||
# - persistent configs saved to data partition
|
||||
#
|
||||
# If no cloud-init file is found, this stage is a no-op and later stages
|
||||
# (50-network, 60-hostname) handle defaults.
|
||||
|
||||
CLOUDINIT_BIN="/usr/lib/kubesolo-os/kubesolo-cloudinit"
|
||||
CLOUDINIT_FILE="${KUBESOLO_CLOUDINIT:-$DATA_MOUNT/etc-kubesolo/cloud-init.yaml}"
|
||||
|
||||
if [ ! -x "$CLOUDINIT_BIN" ]; then
|
||||
log_warn "cloud-init binary not found at $CLOUDINIT_BIN — skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "$CLOUDINIT_FILE" ]; then
|
||||
log "No cloud-init config found at $CLOUDINIT_FILE — skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "Applying cloud-init from: $CLOUDINIT_FILE"
|
||||
|
||||
if "$CLOUDINIT_BIN" apply "$CLOUDINIT_FILE"; then
|
||||
log_ok "cloud-init applied successfully"
|
||||
# Signal to later stages that cloud-init handled network/hostname
|
||||
CLOUDINIT_APPLIED=1
|
||||
export CLOUDINIT_APPLIED
|
||||
else
|
||||
log_err "cloud-init apply failed — later stages will use defaults"
|
||||
fi
|
||||
Reference in New Issue
Block a user