From 4f694ce8c5cc93ea204d51d14f8b0d7867ad3707 Mon Sep 17 00:00:00 2001 From: Vegard Hagen Date: Fri, 18 Apr 2025 17:28:51 +0200 Subject: [PATCH] chore(tofu): run tofu fmt on configuration --- tofu/home-assistant/image.tofu | 12 ++--- tofu/home-assistant/variables.auto.tfvars | 2 +- tofu/home-assistant/variables.tofu | 2 +- tofu/home-assistant/vm.tofu | 2 +- .../bootstrap/sealed-secrets/config.tofu | 2 +- .../volumes/persistent-volume/variables.tofu | 22 ++++----- .../volumes/proxmox-volume/variables.tofu | 10 ++-- .../bootstrap/volumes/variables.tofu | 8 ++-- tofu/kubernetes/main.tofu | 6 +-- tofu/kubernetes/providers.tofu | 6 +-- tofu/kubernetes/talos/config.tofu | 24 +++++----- tofu/kubernetes/talos/image.tofu | 8 ++-- tofu/kubernetes/talos/variables.tofu | 42 ++++++++-------- tofu/kubernetes/talos_cluster.auto.tfvars | 16 +++---- tofu/kubernetes/variables.tofu | 48 +++++++++---------- 15 files changed, 105 insertions(+), 105 deletions(-) diff --git a/tofu/home-assistant/image.tofu b/tofu/home-assistant/image.tofu index b6cafa7..1cf4f14 100644 --- a/tofu/home-assistant/image.tofu +++ b/tofu/home-assistant/image.tofu @@ -1,21 +1,21 @@ resource "null_resource" "haos_image" { triggers = { on_version_change = var.haos_version - filename = var.local_file + filename = var.local_file } provisioner "local-exec" { command = "curl -s -L ${var.haos_download_url}/${var.haos_version}/haos_ova-${var.haos_version}.qcow2.xz | xz -d > ${var.local_file}" } - provisioner "local-exec" { - when = destroy - command = "rm ${self.triggers.filename}" - } + provisioner "local-exec" { + when = destroy + command = "rm ${self.triggers.filename}" + } } resource "proxmox_virtual_environment_file" "haos_generic_image" { - depends_on = [null_resource.haos_image] + depends_on = [null_resource.haos_image] node_name = var.proxmox_cluster.name datastore_id = var.proxmox_cluster.image_datastore diff --git a/tofu/home-assistant/variables.auto.tfvars b/tofu/home-assistant/variables.auto.tfvars index 3f356be..a97f100 100644 --- a/tofu/home-assistant/variables.auto.tfvars +++ b/tofu/home-assistant/variables.auto.tfvars @@ -6,4 +6,4 @@ proxmox_cluster = { image_datastore = "local" } -haos_version = "12.4" +haos_version = "12.4" diff --git a/tofu/home-assistant/variables.tofu b/tofu/home-assistant/variables.tofu index d9d0f27..f685c9f 100644 --- a/tofu/home-assistant/variables.tofu +++ b/tofu/home-assistant/variables.tofu @@ -9,7 +9,7 @@ variable "proxmox_cluster" { } variable "proxmox_api_token" { - type = string + type = string sensitive = true } diff --git a/tofu/home-assistant/vm.tofu b/tofu/home-assistant/vm.tofu index 6ce1ba0..cef9713 100644 --- a/tofu/home-assistant/vm.tofu +++ b/tofu/home-assistant/vm.tofu @@ -3,7 +3,7 @@ resource "proxmox_virtual_environment_vm" "home_assistant" { name = "Home-Assistant" description = "Managed by OpenTofu" - tags = ["home-assistant"] + tags = ["home-assistant"] on_boot = true bios = "ovmf" scsi_hardware = "virtio-scsi-single" diff --git a/tofu/kubernetes/bootstrap/sealed-secrets/config.tofu b/tofu/kubernetes/bootstrap/sealed-secrets/config.tofu index 1643e8f..7ba2b87 100644 --- a/tofu/kubernetes/bootstrap/sealed-secrets/config.tofu +++ b/tofu/kubernetes/bootstrap/sealed-secrets/config.tofu @@ -6,7 +6,7 @@ resource "kubernetes_namespace" "sealed-secrets" { resource "kubernetes_secret" "sealed-secrets-key" { depends_on = [kubernetes_namespace.sealed-secrets] - type = "kubernetes.io/tls" + type = "kubernetes.io/tls" metadata { name = "sealed-secrets-bootstrap-key" diff --git a/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tofu b/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tofu index 8ae5e10..7784758 100644 --- a/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tofu +++ b/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tofu @@ -1,17 +1,17 @@ variable "volume" { description = "Volume configuration" type = object({ - name = string - capacity = string - volume_handle = string - access_modes = optional(list(string), ["ReadWriteOnce"]) + name = string + capacity = string + volume_handle = string + access_modes = optional(list(string), ["ReadWriteOnce"]) storage_class_name = optional(string, "proxmox-csi") - fs_type = optional(string, "ext4") - driver = optional(string, "csi.proxmox.sinextra.dev") - volume_mode = optional(string, "Filesystem") - mount_options = optional(list(string), ["noatime"]) - cache = optional(string, "writethrough") - ssd = optional(bool, true) - storage = optional(string, "local-zfs") + fs_type = optional(string, "ext4") + driver = optional(string, "csi.proxmox.sinextra.dev") + volume_mode = optional(string, "Filesystem") + mount_options = optional(list(string), ["noatime"]) + cache = optional(string, "writethrough") + ssd = optional(bool, true) + storage = optional(string, "local-zfs") }) } diff --git a/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tofu b/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tofu index 5476a5f..ffecd7c 100644 --- a/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tofu +++ b/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tofu @@ -1,10 +1,10 @@ variable "volume" { type = object({ - name = string - node = string - size = string + name = string + node = string + size = string storage = optional(string, "local-zfs") - vmid = optional(number, 9999) - format = optional(string, "raw") + vmid = optional(number, 9999) + format = optional(string, "raw") }) } diff --git a/tofu/kubernetes/bootstrap/volumes/variables.tofu b/tofu/kubernetes/bootstrap/volumes/variables.tofu index dfc2833..405943a 100644 --- a/tofu/kubernetes/bootstrap/volumes/variables.tofu +++ b/tofu/kubernetes/bootstrap/volumes/variables.tofu @@ -9,11 +9,11 @@ variable "proxmox_api" { variable "volumes" { type = map( object({ - node = string - size = string + node = string + size = string storage = optional(string, "local-zfs") - vmid = optional(number, 9999) - format = optional(string, "raw") + vmid = optional(number, 9999) + format = optional(string, "raw") }) ) } diff --git a/tofu/kubernetes/main.tofu b/tofu/kubernetes/main.tofu index 7d441db..fb7510a 100644 --- a/tofu/kubernetes/main.tofu +++ b/tofu/kubernetes/main.tofu @@ -12,7 +12,7 @@ module "talos" { module "sealed_secrets" { depends_on = [module.talos] - source = "./bootstrap/sealed-secrets" + source = "./bootstrap/sealed-secrets" providers = { kubernetes = kubernetes @@ -23,7 +23,7 @@ module "sealed_secrets" { module "proxmox_csi_plugin" { depends_on = [module.talos] - source = "./bootstrap/proxmox-csi-plugin" + source = "./bootstrap/proxmox-csi-plugin" providers = { proxmox = proxmox @@ -35,7 +35,7 @@ module "proxmox_csi_plugin" { module "volumes" { depends_on = [module.proxmox_csi_plugin] - source = "./bootstrap/volumes" + source = "./bootstrap/volumes" providers = { restapi = restapi diff --git a/tofu/kubernetes/providers.tofu b/tofu/kubernetes/providers.tofu index dfdcf4f..cfba061 100644 --- a/tofu/kubernetes/providers.tofu +++ b/tofu/kubernetes/providers.tofu @@ -42,8 +42,8 @@ provider "restapi" { } provider "kubernetes" { - host = module.talos.kube_config.kubernetes_client_configuration.host - client_certificate = base64decode(module.talos.kube_config.kubernetes_client_configuration.client_certificate) - client_key = base64decode(module.talos.kube_config.kubernetes_client_configuration.client_key) + host = module.talos.kube_config.kubernetes_client_configuration.host + client_certificate = base64decode(module.talos.kube_config.kubernetes_client_configuration.client_certificate) + client_key = base64decode(module.talos.kube_config.kubernetes_client_configuration.client_key) cluster_ca_certificate = base64decode(module.talos.kube_config.kubernetes_client_configuration.ca_certificate) } diff --git a/tofu/kubernetes/talos/config.tofu b/tofu/kubernetes/talos/config.tofu index df78322..67ca7f6 100644 --- a/tofu/kubernetes/talos/config.tofu +++ b/tofu/kubernetes/talos/config.tofu @@ -1,6 +1,6 @@ locals { first_control_plane_node_ip = [for k, v in var.nodes : v.ip if v.machine_type == "controlplane"][0] - kubernetes_endpoint = coalesce(var.cluster.vip, local.first_control_plane_node_ip) + kubernetes_endpoint = coalesce(var.cluster.vip, local.first_control_plane_node_ip) extra_manifests = concat(var.cluster.extra_manifests, [ "https://github.com/kubernetes-sigs/gateway-api/releases/download/${var.cluster.gateway_api_version}/standard-install.yaml", "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${var.cluster.gateway_api_version}/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml" @@ -21,7 +21,7 @@ data "talos_client_configuration" "this" { resource "terraform_data" "cilium_bootstrap_inline_manifests" { input = [ { - name = "cilium-bootstrap" + name = "cilium-bootstrap" contents = file("${path.root}/${var.cluster.cilium.bootstrap_manifest_path}") }, { @@ -42,8 +42,8 @@ resource "terraform_data" "cilium_bootstrap_inline_manifests" { } data "talos_machine_configuration" "this" { - for_each = var.nodes - cluster_name = var.cluster.name + for_each = var.nodes + cluster_name = var.cluster.name # This is the Kubernetes API Server endpoint. # ref - https://www.talos.dev/latest/introduction/prodnotes/#decide-the-kubernetes-endpoint cluster_endpoint = "https://${local.kubernetes_endpoint}:6443" @@ -59,22 +59,22 @@ data "talos_machine_configuration" "this" { kubernetes_version = var.cluster.kubernetes_version hostname = each.key ip = each.value.ip - mac_address = lower(each.value.mac_address) + mac_address = lower(each.value.mac_address) gateway = var.cluster.gateway subnet_mask = var.cluster.subnet_mask vip = var.cluster.vip }), each.value.machine_type == "controlplane" ? - templatefile("${path.module}/machine-config/control-plane.yaml.tftpl", { - kubelet = var.cluster.kubelet - extra_manifests = jsonencode(local.extra_manifests) - api_server = var.cluster.api_server - inline_manifests = jsonencode(terraform_data.cilium_bootstrap_inline_manifests.output) - }) : "" + templatefile("${path.module}/machine-config/control-plane.yaml.tftpl", { + kubelet = var.cluster.kubelet + extra_manifests = jsonencode(local.extra_manifests) + api_server = var.cluster.api_server + inline_manifests = jsonencode(terraform_data.cilium_bootstrap_inline_manifests.output) + }) : "" ] } resource "talos_machine_configuration_apply" "this" { - depends_on = [proxmox_virtual_environment_vm.this] + depends_on = [proxmox_virtual_environment_vm.this] for_each = var.nodes node = each.value.ip client_configuration = talos_machine_secrets.this.client_configuration diff --git a/tofu/kubernetes/talos/image.tofu b/tofu/kubernetes/talos/image.tofu index 9e8ba92..c9278a4 100644 --- a/tofu/kubernetes/talos/image.tofu +++ b/tofu/kubernetes/talos/image.tofu @@ -1,12 +1,12 @@ locals { version = var.image.version - schematic = file("${path.root}/${var.image.schematic_path}") + schematic = file("${path.root}/${var.image.schematic_path}") schematic_id = jsondecode(data.http.schematic_id.response_body)["id"] - update_version = coalesce(var.image.update_version, var.image.version) + update_version = coalesce(var.image.update_version, var.image.version) update_schematic_path = coalesce(var.image.update_schematic_path, var.image.schematic_path) - update_schematic = file("${path.root}/${local.update_schematic_path}") - update_schematic_id = jsondecode(data.http.updated_schematic_id.response_body)["id"] + update_schematic = file("${path.root}/${local.update_schematic_path}") + update_schematic_id = jsondecode(data.http.updated_schematic_id.response_body)["id"] image_id = "${local.schematic_id}_${local.version}" update_image_id = "${local.update_schematic_id}_${local.update_version}" diff --git a/tofu/kubernetes/talos/variables.tofu b/tofu/kubernetes/talos/variables.tofu index 912845a..a2af3b5 100644 --- a/tofu/kubernetes/talos/variables.tofu +++ b/tofu/kubernetes/talos/variables.tofu @@ -1,31 +1,31 @@ variable "image" { description = "Talos image configuration" type = object({ - factory_url = optional(string, "https://factory.talos.dev") - schematic_path = string - version = string + factory_url = optional(string, "https://factory.talos.dev") + schematic_path = string + version = string update_schematic_path = optional(string) - update_version = optional(string) - arch = optional(string, "amd64") - platform = optional(string, "nocloud") - proxmox_datastore = optional(string, "local") + update_version = optional(string) + arch = optional(string, "amd64") + platform = optional(string, "nocloud") + proxmox_datastore = optional(string, "local") }) } variable "cluster" { description = "Cluster configuration" type = object({ - name = string - vip = optional(string) - gateway = string - subnet_mask = optional(string, "24") + name = string + vip = optional(string) + gateway = string + subnet_mask = optional(string, "24") talos_machine_config_version = optional(string) - proxmox_cluster = string - kubernetes_version = string - gateway_api_version = string - extra_manifests = optional(list(string)) - kubelet = optional(string) - api_server = optional(string) + proxmox_cluster = string + kubernetes_version = string + gateway_api_version = string + extra_manifests = optional(list(string)) + kubelet = optional(string) + api_server = optional(string) cilium = object({ bootstrap_manifest_path = string values_file_path = string @@ -38,14 +38,14 @@ variable "nodes" { type = map(object({ host_node = string machine_type = string - datastore_id = optional(string, "local-zfs") + datastore_id = optional(string, "local-zfs") ip = string - dns = optional(list(string)) + dns = optional(list(string)) mac_address = string vm_id = number cpu = number ram_dedicated = number - update = optional(bool, false) - igpu = optional(bool, false) + update = optional(bool, false) + igpu = optional(bool, false) })) } diff --git a/tofu/kubernetes/talos_cluster.auto.tfvars b/tofu/kubernetes/talos_cluster.auto.tfvars index f664de2..9f4c769 100644 --- a/tofu/kubernetes/talos_cluster.auto.tfvars +++ b/tofu/kubernetes/talos_cluster.auto.tfvars @@ -1,27 +1,27 @@ talos_cluster_config = { - name = "talos" + name = "talos" # Only use a VIP if the nodes share a layer 2 network # Ref: https://www.talos.dev/v1.9/talos-guides/network/vip/#requirements - vip = "192.168.1.99" - gateway = "192.168.1.1" + vip = "192.168.1.99" + gateway = "192.168.1.1" # The version of talos features to use in generated machine configuration. Generally the same as image version. # See https://github.com/siderolabs/terraform-provider-talos/blob/main/docs/data-sources/machine_configuration.md # Uncomment to use this instead of version from talos_image. # talos_machine_config_version = "v1.9.2" - proxmox_cluster = "homelab" - kubernetes_version = "v1.32.3" # renovate: github-releases=kubernetes/kubernetes + proxmox_cluster = "homelab" + kubernetes_version = "v1.32.3" # renovate: github-releases=kubernetes/kubernetes cilium = { bootstrap_manifest_path = "talos/inline-manifests/cilium-install.yaml" values_file_path = "../../k8s/infra/network/cilium/values.yaml" } gateway_api_version = "v1.2.1" # renovate: github-releases=kubernetes-sigs/gateway-api - extra_manifests = [] - kubelet = <<-EOT + extra_manifests = [] + kubelet = <<-EOT extraArgs: # Needed for Netbird agent https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/#enabling-unsafe-sysctls allowed-unsafe-sysctls: net.ipv4.conf.all.src_valid_mark EOT - api_server = <<-EOT + api_server = <<-EOT extraArgs: oidc-issuer-url: "https://authelia.stonegarden.dev" oidc-client-id: "kubectl" diff --git a/tofu/kubernetes/variables.tofu b/tofu/kubernetes/variables.tofu index abd7010..b2035b0 100644 --- a/tofu/kubernetes/variables.tofu +++ b/tofu/kubernetes/variables.tofu @@ -18,30 +18,30 @@ variable "proxmox_api_token" { variable "talos_image" { description = "Talos image configuration" type = object({ - factory_url = optional(string, "https://factory.talos.dev") - version = string - schematic_path = string - update_version = optional(string) + factory_url = optional(string, "https://factory.talos.dev") + version = string + schematic_path = string + update_version = optional(string) update_schematic_path = optional(string) - arch = optional(string, "amd64") - platform = optional(string, "nocloud") - proxmox_datastore = optional(string, "local") + arch = optional(string, "amd64") + platform = optional(string, "nocloud") + proxmox_datastore = optional(string, "local") }) } variable "talos_cluster_config" { description = "Talos cluster configuration" type = object({ - name = string - vip = optional(string) - gateway = string + name = string + vip = optional(string) + gateway = string talos_machine_config_version = optional(string) - proxmox_cluster = string - kubernetes_version = string - gateway_api_version = string - extra_manifests = optional(list(string), []) - kubelet = optional(string) - api_server = optional(string) + proxmox_cluster = string + kubernetes_version = string + gateway_api_version = string + extra_manifests = optional(list(string), []) + kubelet = optional(string) + api_server = optional(string) cilium = object({ bootstrap_manifest_path = string values_file_path = string @@ -55,18 +55,18 @@ variable "talos_nodes" { host_node = string machine_type = string ip = string - dns = optional(list(string)) + dns = optional(list(string)) mac_address = string vm_id = number cpu = number ram_dedicated = number - update = optional(bool, false) - igpu = optional(bool, false) + update = optional(bool, false) + igpu = optional(bool, false) }) ) validation { // @formatter:off - condition = length([for n in var.talos_nodes : n if contains(["controlplane", "worker"], n.machine_type)]) == length(var.talos_nodes) + condition = length([for n in var.talos_nodes : n if contains(["controlplane", "worker"], n.machine_type)]) == length(var.talos_nodes) error_message = "Node machine_type must be either 'controlplane' or 'worker'." // @formatter:on } @@ -83,11 +83,11 @@ variable "sealed_secrets_config" { variable "kubernetes_volumes" { type = map( object({ - node = string - size = string + node = string + size = string storage = optional(string, "local-zfs") - vmid = optional(number, 9999) - format = optional(string, "raw") + vmid = optional(number, 9999) + format = optional(string, "raw") }) ) }