output "control_plane_ips" {
  description = "Public IPs of control plane nodes"
  value       = var.control_plane_ips
}

output "control_plane_names" {
  description = "Control plane hostnames"
  value       = [for idx in range(var.control_plane_count) : format("%s-cp-%d", var.cluster_name, idx + 1)]
}

output "control_plane_private_ips" {
  description = "Private IPs of control plane nodes"
  value       = var.control_plane_ips
}

output "primary_control_plane_ip" {
  description = "Public IP of the primary control plane (first node)"
  value       = var.control_plane_ips[0]
}

output "worker_ips" {
  description = "Public IPs of worker nodes"
  value       = var.worker_ips
}

output "worker_names" {
  description = "Worker hostnames"
  value       = [for idx in range(var.worker_count) : format("%s-worker-%d", var.cluster_name, idx + 1)]
}

output "worker_private_ips" {
  description = "Private IPs of worker nodes"
  value       = var.worker_ips
}

output "ssh_private_key_path" {
  description = "Path to SSH private key"
  value       = var.ssh_private_key
}

output "cluster_name" {
  description = "Cluster name"
  value       = var.cluster_name
}

output "tailscale_tailnet" {
  description = "Tailnet domain suffix"
  value       = var.tailscale_tailnet
}

output "network_cidr" {
  description = "Private network CIDR"
  value       = var.subnet_cidr
}

output "kubeconfig_command" {
  description = "Command to fetch kubeconfig"
  value       = "ssh ubuntu@${var.control_plane_ips[0]} 'sudo cat /etc/rancher/k3s/k3s.yaml' > kubeconfig && sed -i 's/127.0.0.1/${var.control_plane_ips[0]}/g' kubeconfig"
}

output "kube_api_lb_ip" {
  description = "Load Balancer private IP for Kubernetes API (used for cluster joins)"
  value       = var.kube_api_vip
}
