From c6c59a82bdcd1400b514d4ca9c1e30f8824df773 Mon Sep 17 00:00:00 2001 From: Henry Whitaker Date: Thu, 1 Feb 2024 00:01:18 +0000 Subject: [PATCH] fix: tfnew proxprov --- .taskfiles/terraform.yaml | 2 +- terraform/.terraform.lock.hcl | 33 +++++++++++---------- terraform/actions.tf | 14 +++++++++ terraform/db.tf | 28 +++++++++--------- terraform/k3s.tf | 56 +++++++++++++++++------------------ terraform/locals.tf | 2 +- terraform/networking.tf | 52 ++++++++++++++++---------------- terraform/providers.tf | 2 +- terraform/vm/main.tf | 18 +++++++---- terraform/vm/varibles.tf | 5 ---- 10 files changed, 115 insertions(+), 97 deletions(-) create mode 100644 terraform/actions.tf diff --git a/.taskfiles/terraform.yaml b/.taskfiles/terraform.yaml index 875a5134..0d6a2162 100644 --- a/.taskfiles/terraform.yaml +++ b/.taskfiles/terraform.yaml @@ -9,7 +9,7 @@ tasks: plan: dir: terraform cmds: - - terraform plan + - terraform plan {{ .CLI_ARGS }} apply: dir: terraform diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index 037531b1..c3d07756 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -143,22 +143,23 @@ provider "registry.terraform.io/ryanwholey/pihole" { } provider "registry.terraform.io/telmate/proxmox" { - version = "2.9.14" - constraints = "2.9.14" + version = "3.0.1-rc1" + constraints = "2.9.14, 3.0.1-rc1" hashes = [ - "h1:42VV9prtdPOC21QwObrKa80QuFLzVtmG/XTocZJnwhE=", - "h1:7UMoH4uoEy+pepu3HvOwfWCt05UmKOpUWmzDGgXFJ6o=", - "h1:DGYFoyIbkjtA0Um19HoQsrAlhxPogcLWyeRMTuOdbx0=", - "h1:H/f+LbVyPOLslHLAYnGuMMRqWFZ65K6E3V+MCYgfAyk=", - "h1:KWPlH228/+BiH8OOY754MTTaUkLJLN/1krSSzqiyNsE=", - "h1:MHuH64IoDoEStuakwCgQG3LhL3sS5ES5zl1utIVgPjo=", - "h1:MR7UtO8gm3HW4rLHBFyvj4PyIrw4X7/WIvujH4V0I4M=", - "h1:QDwNQQT8tJ6iVDn7bzcUSIiBUOSuGl386yEdIPGmzl4=", - "h1:R4gRIvrfxjJ8qm3CslbssfAXAIK3KnfZSaIX7Hsxygo=", - "h1:W6AG2PxnKBt+evCrtFAiYUJsb1la2Cw2KACt90RKKYE=", - "h1:asZa5VKbWeCpLNv1JAutt5CdD27HaGFjxxcr6mvn8Ps=", - "h1:pGOSVLWxO2JkfBovOYvBhPesbDO7HoWBhlO9GNyOE2Q=", - "h1:r0QRgvTEzlVPBvyyTdTZ3FeIeGH+bR8LOz8QaME8mq0=", - "h1:r0gQ2xTCMUZfaZZ5HgoxWxg3WDNXCy3J4qHOO6UP51s=", + "h1:4xZeGV+uRpYX6Boe0kWI3Dw3B+x8P4tT4JTnUpE1FJU=", + "zh:4c4a5739ed8b0fdec644632de9cc3219a31022b03aaaf6b77d49efe58541d5c1", + "zh:5c97c58a1d15d3b77bade630c70c75f24cf884560625afa78f408f682c09cc05", + "zh:6b3b8a410cdf39a1cd9dffc2e62806ff91e23a77ccc310fd1ea130560a2f6634", + "zh:73fb750e3363cb1eefacd5fc714a93b9cd65f55459981eb27dd7f4ab7ae5aed7", + "zh:7b4bd5db2188cd21df1d7a49cbf893a18aaa915add400242b20f82cba41d3606", + "zh:8427be708a485325bb0cf70ff9470256e388353b80a554772f19103edf208107", + "zh:9bd7ffdcf8e19efcc90bdef55871d9e6c6d8bcaf46d6873d7faa01709154129c", + "zh:9f7dfe0f4c59fb593f936c67901e851fdfa279fa2aa5ae8f5fff29e763487861", + "zh:a61fd2386c116dd4ed1e202c10b4a3378290d29411f47f0460ba7b8d13e14c53", + "zh:cbe1be50efe3608d014c05503d65d8a3a98cec87962a8a0fdd95065b85db6d4f", + "zh:cdb175a0cb863a11090edbd50500b7d55137dbbb0d31fd119d727e12cadc6b4a", + "zh:cee3e0ed0ecaec22e58e5cec4fb202fb4f2a6779a87ef57c464c7b9c825f4c37", + "zh:e5d4e4fc9619bcfaaed159f9404457f29385dcb2f8fc42cf1b2dab4de7bdbf21", + "zh:f39ec72a5e8624949592d48dec11ef6abb811d0ae5a80b6fe356a47392a38a6a", ] } diff --git a/terraform/actions.tf b/terraform/actions.tf new file mode 100644 index 00000000..f340521e --- /dev/null +++ b/terraform/actions.tf @@ -0,0 +1,14 @@ +module "actions" { + source = "./vm" + + name = "actions" + image = local.ubuntu_22_04 + ip = "10.0.0.18" + memory = 2048 + cores = 2 + nameserver = "1.1.1.1 8.8.8.8" + node = 2 + disk_size = "8G" + + tags = ["srep", "ubuntu"] +} diff --git a/terraform/db.tf b/terraform/db.tf index bdbde085..3741edd1 100644 --- a/terraform/db.tf +++ b/terraform/db.tf @@ -1,27 +1,27 @@ module "mariadb-1" { source = "./vm" - name = "mariadb-1" - image = local.ubuntu_22_04 - ip = "10.0.0.15" - cores = 2 - memory = 2048 - node = 1 + name = "mariadb-1" + image = local.ubuntu_22_04 + ip = "10.0.0.15" + cores = 2 + memory = 2048 + node = 1 disk_size = "25G" - tags = [ "database", "ubuntu" ] + tags = ["database", "ubuntu"] } module "mariadb-2" { source = "./vm" - name = "mariadb-2" - image = local.ubuntu_22_04 - ip = "10.0.0.16" - cores = 2 - memory = 2048 - node = 2 + name = "mariadb-2" + image = local.ubuntu_22_04 + ip = "10.0.0.16" + cores = 2 + memory = 2048 + node = 2 disk_size = "25G" - tags = [ "database", "ubuntu" ] + tags = ["database", "ubuntu"] } diff --git a/terraform/k3s.tf b/terraform/k3s.tf index 583e3925..4be2f335 100644 --- a/terraform/k3s.tf +++ b/terraform/k3s.tf @@ -1,55 +1,55 @@ module "k3s-control-1" { source = "./vm" - name = "k3s-control-1" - image = local.ubuntu_22_04 - ip = "10.0.0.23" - cores = 3 - memory = 12288 - node = 1 + name = "k3s-control-1" + image = local.ubuntu_22_04 + ip = "10.0.0.23" + cores = 3 + memory = 12288 + node = 1 disk_size = "200G" - tags = [ "control", "k3s", "ubuntu" ] + tags = ["control", "k3s", "ubuntu"] } module "k3s-control-2" { source = "./vm" - name = "k3s-control-2" - image = local.ubuntu_22_04 - ip = "10.0.0.22" - cores = 3 - memory = 12288 - node = 2 + name = "k3s-control-2" + image = local.ubuntu_22_04 + ip = "10.0.0.22" + cores = 3 + memory = 12288 + node = 2 disk_size = "200G" - tags = [ "control", "k3s", "ubuntu" ] + tags = ["control", "k3s", "ubuntu"] } module "k3s-worker-1" { source = "./vm" - name = "k3s-worker-1" - image = local.ubuntu_22_04 - ip = "10.0.0.20" - cores = 2 - memory = 8192 - node = 1 + name = "k3s-worker-1" + image = local.ubuntu_22_04 + ip = "10.0.0.20" + cores = 2 + memory = 8192 + node = 1 disk_size = "200G" - tags = [ "agent", "k3s", "ubuntu" ] + tags = ["agent", "k3s", "ubuntu"] } module "k3s-worker-2" { source = "./vm" - name = "k3s-worker-2" - image = local.ubuntu_22_04 - ip = "10.0.0.21" - cores = 2 - memory = 8192 - node = 2 + name = "k3s-worker-2" + image = local.ubuntu_22_04 + ip = "10.0.0.21" + cores = 2 + memory = 8192 + node = 2 disk_size = "200G" - tags = [ "agent", "k3s", "ubuntu" ] + tags = ["agent", "k3s", "ubuntu"] } diff --git a/terraform/locals.tf b/terraform/locals.tf index 8a55035b..e5e10f7b 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -1,5 +1,5 @@ locals { proxmox_host = "10.0.0.150" - ubuntu_22_04 = "ubuntu-22.04-cloud" + ubuntu_22_04 = "ubuntu-22.04-cloud" } diff --git a/terraform/networking.tf b/terraform/networking.tf index 46647115..6621fe03 100644 --- a/terraform/networking.tf +++ b/terraform/networking.tf @@ -7,59 +7,59 @@ module "pihole" { memory = 2048 nameserver = "1.1.1.1 8.8.8.8" node = 2 - disk_size = "8G" + disk_size = "8G" - tags = [ "dns", "networking", "ubuntu" ] + tags = ["dns", "networking", "ubuntu"] } module "lb-1" { source = "./vm" - name = "lb-1" - image = local.ubuntu_22_04 - ip = "10.0.0.4" - memory = 512 - node = 1 + name = "lb-1" + image = local.ubuntu_22_04 + ip = "10.0.0.4" + memory = 512 + node = 1 disk_size = "8G" - tags = [ "lb", "networking", "ubuntu" ] + tags = ["lb", "networking", "ubuntu"] } module "lb-2" { source = "./vm" - name = "lb-2" - image = local.ubuntu_22_04 - ip = "10.0.0.5" - memory = 512 - node = 2 + name = "lb-2" + image = local.ubuntu_22_04 + ip = "10.0.0.5" + memory = 512 + node = 2 disk_size = "8G" - tags = [ "lb", "networking", "ubuntu" ] + tags = ["lb", "networking", "ubuntu"] } module "vpn-1" { source = "./vm" - name = "vpn-1" - image = local.ubuntu_22_04 - ip = "10.0.0.11" - memory = 512 - node = 1 + name = "vpn-1" + image = local.ubuntu_22_04 + ip = "10.0.0.11" + memory = 512 + node = 1 disk_size = "8G" - tags = [ "networking", "ubuntu", "vpn" ] + tags = ["networking", "ubuntu", "vpn"] } module "vpn-2" { source = "./vm" - name = "vpn-2" - image = local.ubuntu_22_04 - ip = "10.0.0.12" - memory = 512 - node = 2 + name = "vpn-2" + image = local.ubuntu_22_04 + ip = "10.0.0.12" + memory = 512 + node = 2 disk_size = "8G" - tags = [ "networking", "ubuntu", "vpn" ] + tags = ["networking", "ubuntu", "vpn"] } diff --git a/terraform/providers.tf b/terraform/providers.tf index ee5dab64..763b993b 100644 --- a/terraform/providers.tf +++ b/terraform/providers.tf @@ -3,7 +3,7 @@ terraform { required_providers { proxmox = { source = "telmate/proxmox" - version = "2.9.14" + version = "3.0.1-rc1" } digitalocean = { diff --git a/terraform/vm/main.tf b/terraform/vm/main.tf index a7813d82..3f991c4f 100644 --- a/terraform/vm/main.tf +++ b/terraform/vm/main.tf @@ -18,11 +18,19 @@ resource "proxmox_vm_qemu" "vm" { qemu_os = "other" additional_wait = 0 clone_wait = 0 - - disk { - size = var.disk_size - storage = var.disk_storage - type = var.disk_type + vm_state = "running" + cloudinit_cdrom_storage = "local-lvm" + + disks { + scsi { + scsi0 { + disk { + size = replace(var.disk_size, "G", "") + storage = var.disk_storage + format = "raw" + } + } + } } tags = join(";", var.tags) diff --git a/terraform/vm/varibles.tf b/terraform/vm/varibles.tf index 526b6b2a..e79bb339 100644 --- a/terraform/vm/varibles.tf +++ b/terraform/vm/varibles.tf @@ -55,11 +55,6 @@ variable "disk_storage" { default = "local-lvm" } -variable "disk_type" { - type = string - default = "scsi" -} - variable "tags" { type = list(string) default = []