Made installation more configurable and removed clutter

This commit is contained in:
Max Pfeiffer
2025-09-12 19:52:44 +02:00
parent cf41134815
commit 5076f167f9
8 changed files with 98 additions and 73 deletions

View File

@@ -2,22 +2,24 @@ resource "talos_machine_secrets" "this" {}
data "talos_machine_configuration" "controlplane" {
cluster_name = var.cluster_name
cluster_endpoint = "https://${var.vip_shared_ip}:6443"
cluster_endpoint = "https://${var.cluster_vip_shared_ip}:6443"
machine_type = "controlplane"
machine_secrets = talos_machine_secrets.this.machine_secrets
talos_version = var.talos_version
}
data "talos_machine_configuration" "worker" {
cluster_name = var.cluster_name
cluster_endpoint = "https://${var.vip_shared_ip}:6443"
cluster_endpoint = "https://${var.cluster_vip_shared_ip}:6443"
machine_type = "worker"
machine_secrets = talos_machine_secrets.this.machine_secrets
talos_version = var.talos_version
}
data "talos_client_configuration" "this" {
cluster_name = var.cluster_name
client_configuration = talos_machine_secrets.this.client_configuration
endpoints = [for k, v in var.node_data.controlplanes : k]
endpoints = concat([var.cluster_vip_shared_ip], [for k, v in var.node_data.controlplanes : k])
}
resource "talos_machine_configuration_apply" "controlplane" {
@@ -28,13 +30,13 @@ resource "talos_machine_configuration_apply" "controlplane" {
node = each.key
config_patches = [
templatefile("${path.module}/templates/machine_config_patches_controlplane.tftpl", {
hostname = each.value.hostname == null ? format("%s-cp-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key)) : each.value.hostname
install_disk = each.value.install_disk
install_image = each.value.install_image
ip_address = "${each.key}/24"
network = var.network
network_gateway = var.network_gateway
vip_shared_ip = var.vip_shared_ip
hostname = each.value.hostname == null ? format("%s-cp-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key)) : each.value.hostname
install_disk = each.value.install_disk
install_image = each.value.install_image
ip_address = "${each.key}/24"
network = var.network
network_gateway = var.network_gateway
vip_shared_ip = var.cluster_vip_shared_ip
}),
]
}
@@ -47,12 +49,12 @@ resource "talos_machine_configuration_apply" "worker" {
node = each.key
config_patches = [
templatefile("${path.module}/templates/machine_config_patches_worker.tftpl", {
hostname = each.value.hostname == null ? format("%s-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key)) : each.value.hostname
install_disk = each.value.install_disk
install_image = each.value.install_image
ip_address = "${each.key}/24"
network = var.network
network_gateway = var.network_gateway
hostname = each.value.hostname == null ? format("%s-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key)) : each.value.hostname
install_disk = each.value.install_disk
install_image = each.value.install_image
ip_address = "${each.key}/24"
network = var.network
network_gateway = var.network_gateway
})
]
}