Skip to content

Commit

Permalink
feat(tofu): use new talos_image_factory_schematic resource
Browse files Browse the repository at this point in the history
talos provider 0.6 added a new resource for generating the image schematic id
  • Loading branch information
vehagn committed Oct 10, 2024
1 parent 1a99660 commit 856cef4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 61 deletions.
4 changes: 2 additions & 2 deletions tofu/kubernetes/bootstrap/proxmox-csi-plugin/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">=2.31.0"
version = ">=2.32.0"
}
proxmox = {
source = "bpg/proxmox"
version = ">=0.60.0"
version = ">=0.66.1"
}
}
}
2 changes: 1 addition & 1 deletion tofu/kubernetes/bootstrap/sealed-secrets/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">=2.31.0"
version = ">=2.32.0"
}
}
}
4 changes: 2 additions & 2 deletions tofu/kubernetes/bootstrap/volumes/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.31.0"
version = ">= 2.32.0"
}
restapi = {
source = "Mastercard/restapi"
version = ">= 1.19.1"
version = ">= 1.12.0"
}
}
}
5 changes: 0 additions & 5 deletions tofu/kubernetes/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ output "talos_config" {
value = module.talos.client_configuration.talos_config
sensitive = true
}

output "image_schematic" {
// "dcac6b92c17d1d8947a0cee5e0e6b6904089aa878c70d66196bb1138dbd05d1a"
value = module.talos.schematic_id
}
51 changes: 2 additions & 49 deletions tofu/kubernetes/talos/image.tf
Original file line number Diff line number Diff line change
@@ -1,56 +1,11 @@
locals {
version = var.image.version
schematic = var.image.schematic
schematic_id = jsondecode(data.http.schematic_id.response_body)["id"]
#schematic_id = talos_image_factory_schematic.this.id
image_id = "${local.schematic_id}_${local.version}"
image_id = "${talos_image_factory_schematic.this.id}_${local.version}"

update_version = coalesce(var.image.update_version, var.image.version)
update_schematic = coalesce(var.image.update_schematic, var.image.schematic)
update_schematic_id = jsondecode(data.http.updated_schematic_id.response_body)["id"]
#update_schematic_id = talos_image_factory_schematic.this.id
update_image_id = "${local.update_schematic_id}_${local.update_version}"
}

data "http" "schematic_id" {
url = "${var.image.factory_url}/schematics"
method = "POST"
request_body = local.schematic
}

data "http" "updated_schematic_id" {
url = "${var.image.factory_url}/schematics"
method = "POST"
request_body = local.update_schematic
}

/* Testing out new provider schematic feature */

data "talos_image_factory_extensions_versions" "this" {
talos_version = var.image.version
filters = {
names = [
"i915-ucode",
"intel-ucode",
"qemu-guest-agent"
]
}
}

resource "talos_image_factory_schematic" "generated" {
schematic = yamlencode(
{
customization = {
systemExtensions = {
officialExtensions = data.talos_image_factory_extensions_versions.this.extensions_info.*.name
}
}
}
)
}

output "schematic_id" {
value = talos_image_factory_schematic.generated.id
update_image_id = "${talos_image_factory_schematic.updated.id}_${local.update_version}"
}

resource "talos_image_factory_schematic" "this" {
Expand All @@ -61,8 +16,6 @@ resource "talos_image_factory_schematic" "updated" {
schematic = local.update_schematic
}

/* Testing out new provider schematic feature */

resource "proxmox_virtual_environment_download_file" "this" {
for_each = toset(distinct([for k, v in var.nodes : "${v.host_node}_${v.update == true ? local.update_image_id : local.image_id}"]))

Expand Down
4 changes: 2 additions & 2 deletions tofu/kubernetes/talos/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">=0.60.0"
version = ">=0.66.1"
}
talos = {
source = "siderolabs/talos"
version = ">=0.6.0-alpha.1"
version = ">=0.6.0"
}
}
}

0 comments on commit 856cef4

Please sign in to comment.