fix: fail fast when terraform node IP outputs are empty
Some checks failed
Terraform Plan / Terraform Plan (push) Has been cancelled
Some checks failed
Terraform Plan / Terraform Plan (push) Has been cancelled
This commit is contained in:
@@ -18,6 +18,28 @@ def map_to_pairs(items: dict[str, str]) -> str:
|
||||
return " ".join(f"{k}={v}" for k, v in ordered)
|
||||
|
||||
|
||||
def require_non_empty_ips(label: str, items: dict[str, str]) -> dict[str, str]:
|
||||
cleaned: dict[str, str] = {}
|
||||
missing: list[str] = []
|
||||
|
||||
for name, ip in items.items():
|
||||
ip_value = (ip or "").strip()
|
||||
if not ip_value:
|
||||
missing.append(name)
|
||||
continue
|
||||
cleaned[name] = ip_value
|
||||
|
||||
if missing:
|
||||
names = ", ".join(sorted(missing, key=natural_key))
|
||||
raise SystemExit(
|
||||
f"Missing IPv4 addresses for {label}: {names}. "
|
||||
"Terraform outputs are present but empty. "
|
||||
"This usually means Proxmox guest IP discovery is unavailable for these VMs yet."
|
||||
)
|
||||
|
||||
return cleaned
|
||||
|
||||
|
||||
def main() -> int:
|
||||
payload = json.load(sys.stdin)
|
||||
|
||||
@@ -27,6 +49,9 @@ def main() -> int:
|
||||
if not cp_map or not wk_map:
|
||||
raise SystemExit("Missing control_plane_vm_ipv4 or worker_vm_ipv4 in terraform output")
|
||||
|
||||
cp_map = require_non_empty_ips("control planes", cp_map)
|
||||
wk_map = require_non_empty_ips("workers", wk_map)
|
||||
|
||||
ssh_user = os.environ.get("KUBEADM_SSH_USER", "").strip() or "micqdf"
|
||||
|
||||
print(f"SSH_USER={ssh_user}")
|
||||
|
||||
Reference in New Issue
Block a user