Fix wild-setup-cluster: continue if secrets already generated; fix talos context detection command.

This commit is contained in:
2025-07-18 08:12:16 -07:00
parent a92d427fc4
commit ceec84b655
2 changed files with 18 additions and 18 deletions

View File

@@ -60,15 +60,16 @@ print_header "Talos Cluster Configuration Generation"
# Ensure required directories exist # Ensure required directories exist
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes" NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
mkdir -p "${NODE_SETUP_DIR}/generated"
# Generate cluster secrets # Check if generated directory already exists and has content
if [ -d "${NODE_SETUP_DIR}/generated" ] && [ "$(ls -A "${NODE_SETUP_DIR}/generated" 2>/dev/null)" ] && [ "$FORCE" = false ]; then
if [ -f "${NODE_SETUP_DIR}/generated/secrets.yaml" ] && [ "$FORCE" = false ]; then print_success "Cluster configuration already exists in ${NODE_SETUP_DIR}/generated/"
print_success "Cluster secrets already exists in ${NODE_SETUP_DIR}/generated/" print_info "Skipping cluster configuration generation"
exit 0 exit 0
fi fi
mkdir -p "${NODE_SETUP_DIR}/generated"
# Prepare directory for generated secrets # Prepare directory for generated secrets
print_info "Generating new cluster secrets..." print_info "Generating new cluster secrets..."
if [ -d "${NODE_SETUP_DIR}/generated" ]; then if [ -d "${NODE_SETUP_DIR}/generated" ]; then

View File

@@ -7,7 +7,6 @@ set -o pipefail
SKIP_INSTALLER=false SKIP_INSTALLER=false
SKIP_HARDWARE=false SKIP_HARDWARE=false
SKIP_CONFIGS=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
@@ -19,10 +18,6 @@ while [[ $# -gt 0 ]]; do
SKIP_HARDWARE=true SKIP_HARDWARE=true
shift shift
;; ;;
--skip-configs)
SKIP_CONFIGS=true
shift
;;
-h|--help) -h|--help)
echo "Usage: $0 [phase-options]" echo "Usage: $0 [phase-options]"
echo "" echo ""
@@ -72,16 +67,20 @@ echo ""
# Generate initial cluster configuration # Generate initial cluster configuration
wild-cluster-config-generate if ! wild-cluster-config-generate; then
print_error "Failed to generate cluster configuration"
exit 1
fi
# Configure Talos cli with our new cluster context # Configure Talos cli with our new cluster context
HAS_CONTEXT=$(talos config get | grep -c "<cluster.name>") CLUSTER_NAME=$(wild-config "cluster.name")
HAS_CONTEXT=$(talosctl config contexts | grep -c "$CLUSTER_NAME" || true)
if [ "$HAS_CONTEXT" -eq 0 ]; then if [ "$HAS_CONTEXT" -eq 0 ]; then
print_info "No Talos context found for cluster <cluster.name>, creating..." print_info "No Talos context found for cluster $CLUSTER_NAME, creating..."
talos config merge ${WC_HOME}/setup/cluster-nodes/generated/talosconfig talosctl config merge ${WC_HOME}/setup/cluster-nodes/generated/talosconfig
talos config use <cluster.name> talosctl config use "$CLUSTER_NAME"
print_success "Talos context for <cluster.name> created and set as current" print_success "Talos context for $CLUSTER_NAME created and set as current"
fi fi
# Talos asset download # Talos asset download
@@ -102,7 +101,7 @@ fi
# Configuration # Configuration
# ============================================================================= # =============================================================================
prompt_if_unset_config "owner.email" "Owner email address" prompt_if_unset_config "operator.email" "Operator email address"
# Configure network settings # Configure network settings
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100") CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
@@ -427,7 +426,7 @@ if [ "${SKIP_HARDWARE}" = false ]; then
# Generate machine config immediately # Generate machine config immediately
print_info "Generating machine configuration for $WORKER_IP..." print_info "Generating machine configuration for $WORKER_IP..."
if wild-cluster-node-machine-config-generate "$WORKER_IP"; then if wild-cluster-node-patch-generate "$WORKER_IP"; then
print_success "Machine configuration generated for $WORKER_IP" print_success "Machine configuration generated for $WORKER_IP"
# Ask if user wants to apply the configuration now # Ask if user wants to apply the configuration now