#!/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