mirror of
https://github.com/outbackdingo/homelab-v.git
synced 2026-08-25 14:53:19 +00:00
chore(tofu): run tofu fmt on configuration
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ proxmox_cluster = {
|
||||
image_datastore = "local"
|
||||
}
|
||||
|
||||
haos_version = "12.4"
|
||||
haos_version = "12.4"
|
||||
|
||||
@@ -9,7 +9,7 @@ variable "proxmox_cluster" {
|
||||
}
|
||||
|
||||
variable "proxmox_api_token" {
|
||||
type = string
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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)
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user