diff --git a/infrastructure-tofu/.terraform.lock.hcl b/infrastructure-tofu/.terraform.lock.hcl new file mode 100644 index 0000000..8d399a1 --- /dev/null +++ b/infrastructure-tofu/.terraform.lock.hcl @@ -0,0 +1,41 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/bpg/proxmox" { + version = "0.43.2" + constraints = "0.43.2" + hashes = [ + "h1:1Ex4FC5yz4Vi2+A2JxY2ZZRkSdBVzI3fudbop83dGLU=", + "zh:07c9357e80cc52c020bd3728e5a00e21b9c06b20ee91d13d0c8ea034c1de4b6f", + "zh:41208bfd4d69f04142a69e9eabd79d4cba99f4fcacd59318aad0265c7b4bfe9e", + "zh:420623a0ae35bee21c00da444c0fbc63d3d6008d71516d90e11512651f25210f", + "zh:4cf21c0245a4fcbfec9edc1c65a5a0f0d83180607d870229ce3761fa25652ac7", + "zh:6f07cab62a60d7adc7a2c3f6fb27057dd70883c02c8ee762aec683743aee16c0", + "zh:75c4c97b110373ee48ad87774d9becbb1e21d55e0a4324f594a3b3cc8d25d73e", + "zh:79b3ab36e5276a1172c661eb60574a330cb502f2de40410f2540a50061a777f7", + "zh:96a8cda572ac540aa6c616eabd2e8dc9399809e8558f6d53a883da2a9fbdede8", + "zh:99a78347944868062bac87e93372672aa0f12422cf82d5a7f13a00805f18d5bd", + "zh:a6d2ff27558114277a9e2db874f5c9c9ee65d0dc5e918f2d9994e3ec9ef0e2b5", + "zh:c220049b7b3890e8b882873f0a4320d5b6ca28cf4b3ff9128a130e86ffbc3209", + "zh:da586199b595f278d4ecfc64e60afa52b15b9183323edde00d74a7ede5abad27", + "zh:f2caa3eefc03dd03f05ce466e98ba6fb9f0b87ece3a7fc35eb73d63f816c13d4", + "zh:f99012369fff51af76557d5616a24ae48d12ef662c6d132aa74db7f6b9d4144b", + ] +} + +provider "registry.opentofu.org/hashicorp/random" { + version = "3.6.0" + hashes = [ + "h1:6QMZ6JACl+V2t8daN5GTlw22EtG7nhc3BbkbJDw2a5M=", + "zh:486a1c921eab5c51a480f2eb0ad85173f207c9b7bb215f3893e58bc38d3b7c75", + "zh:6901b3afa4607d1e31934ba91ed2625215ada42b3518c3a9adeeac7a5f656dc3", + "zh:7e93752c9de710e417191353ad1a41b5a60432ab7ef4f8b556bf248297ec5e23", + "zh:c795d3d319e8ee7be972746b935963b7e772a6a14080261a35c03915c1f9ccb2", + "zh:cd4f8bcaf332828d1736c73874549c25e427737f136173c7b61e2df3db50e5d9", + "zh:e0103eb2e280989c3d9ffda5d6b413e8f583be21bc1d5754c6e9ca87ecc1c44a", + "zh:f4fbec2510322d5b7ad584a92436b5dbd0f2e897a3ec538932af59e245a4c8e4", + "zh:f5418842afd4aa7676e2456e425e8f573cb2b9bffd29bd7de09d91845644ab24", + "zh:f572a26f93d00ec42461ce478678366e570fa4497e2273f9d47f24cdfc4b42b4", + "zh:ff1f07c561a3f7f219b6fee1647a559933b5dd6181753e164c3978fd47a11685", + ] +} diff --git a/infrastructure-tofu/k3s.tf b/infrastructure-tofu/k3s.tf new file mode 100644 index 0000000..478f08d --- /dev/null +++ b/infrastructure-tofu/k3s.tf @@ -0,0 +1,75 @@ +# proxmox_virtual_environment_vm.devops: + +resource "proxmox_virtual_environment_vm" "k3s" { + vm_id = "202" + name = "k3s" + node_name = "proxmox" + acpi = false + + clone { + vm_id = 9999 + } + + initialization { + datastore_id = "local" + interface = "ide2" + user_account { + keys = var.virtual_environment_sshkeys + username = "tim" + password = random_password.k3s_vm_password.result + } + ip_config { + ipv4 { + address = "dhcp" + } + ipv6 { + address = "auto" + } + } + } + + disk { + datastore_id = "local" + interface = "scsi0" + size = 50 + discard = "on" + ssd = true + iothread = true + } + + cpu { + cores = 2 + flags = [] + hotplugged = 0 + numa = false + sockets = 1 + type = "host" + } + + memory { + dedicated = 4096 + floating = 0 + shared = 0 + } + + network_device { + bridge = "vmbr0" + enabled = true + firewall = false + model = "virtio" + mtu = 0 + rate_limit = 0 + vlan_id = 0 + } +} + +resource "random_password" "k3s_vm_password" { + length = 16 + override_special = "_%@" + special = true +} + +output "k3s_packer_vm_password" { + value = random_password.k3s_vm_password.result + sensitive = true +} \ No newline at end of file diff --git a/infrastructure-tofu/main.tf b/infrastructure-tofu/main.tf new file mode 100644 index 0000000..3d76c21 --- /dev/null +++ b/infrastructure-tofu/main.tf @@ -0,0 +1,33 @@ +terraform { + required_providers { + proxmox = { + source = "bpg/proxmox" + version = "0.43.2" + } + } + backend "s3" { + bucket = "tofu-remote-state" + key = "tofu.tfstate" + + endpoint = "http://10.20.1.5:9000" + + access_key = "GeOhlbqGrL9KS1fZW06C" + secret_key = "PxWWN2KuK7m0GLLfH45sDTB0e4DhrSseL4KfmR8m" + + region = "main" + skip_credentials_validation = true + skip_metadata_api_check = true + skip_region_validation = true + force_path_style = true + } +} + +provider "proxmox" { + endpoint = var.virtual_environment_endpoint + api_token = var.virtual_environment_api_token + insecure = true + ssh { + agent = true + username = "root" + } +} \ No newline at end of file diff --git a/infrastructure-tofu/resources.tf b/infrastructure-tofu/resources.tf new file mode 100644 index 0000000..c3ed34e --- /dev/null +++ b/infrastructure-tofu/resources.tf @@ -0,0 +1,10 @@ +resource "proxmox_virtual_environment_file" "debian_cloud_image" { + content_type = "iso" + datastore_id = "local" + node_name = "proxmox" + + source_file { + path = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2" + file_name = "debian-12-genericcloud.img" + } +} \ No newline at end of file diff --git a/infrastructure-tofu/variables.tf b/infrastructure-tofu/variables.tf new file mode 100644 index 0000000..af6a6b1 --- /dev/null +++ b/infrastructure-tofu/variables.tf @@ -0,0 +1,17 @@ +variable "virtual_environment_endpoint" { + type = string +} + +variable "virtual_environment_api_token" { + type = string + sensitive = true +} + +variable "virtual_environment_sshkeys" { + type = list(any) + default = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHRYu07KxH1k+RvQ0JjDeLslwEgmWNdU5xtgYXCHoG7L tim@matabi", + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC6xkvp6hi1jat9640TMk3q3YwrsmwCDTmnMJTCsrCPn45JahGOA+nE8hrb75yd0WQb8Khn/prWfwWDaXzxg70pDuznlXfOnvATB0zPdNJngEM3vmo2U1bCnICCxKWRiGTH10LHb8ZGy0rRNDubryRWsIcxE4Vrp07e+suPkLjd55dKEsxz5G0lK7dMmEHlMy0Cy4tVBQlws0kFLtWLu3xL0TGRvhM0nrKNyHlRlOgWN1FIymukkpXLT71YwMidTr2y7fhmYP6qZB/2tKJT/4GzKsvfyHmzKxZgRXOJCUiu1mb9WIJ4wGDX9KVkAoCmH6yK1XulEib9+OeskolyYsdYGmpSFcFb9/6eHLEA94inHqe5xzLNnZMotzkEGy0xPH61c0TrUV5J8JU6jKtnl+F2VRPeemw7Y3nNDqka2O0U9AQDchjoHl7VvAWcV7XUyS9L/ve8FsHNRXpG9t6AJWd92MOPs2F9jXGbVDwwNrRhDp1emc0yKi4KxsSNlF+gvC4uD+p2IWhWoQSY4BYvxwK063fvTTu3xNUPL8EV8oX4E2+IzKJwwOIRawyjJuEfIGUA27ye7VrCkc/LOgpHU/lM7NzutBMBTKLJb012BncvZ14B6R3LeUuCKqN8qrhv2tbW4UIzhhn1g1+Wov7PFAOC/i6oDqsxOWh2heEX2UMKQQ== tim@matabi", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH5NG/v7MCI0X1H35XtJ12MolATQo3bm9L5eCElmNHx7 tim.unkrig@frafos.support", + ] +} \ No newline at end of file diff --git a/infrastructure/.terraform.lock.hcl b/infrastructure/.terraform.lock.hcl index 1a7372a..3ab141f 100644 --- a/infrastructure/.terraform.lock.hcl +++ b/infrastructure/.terraform.lock.hcl @@ -1,7 +1,7 @@ -# This file is maintained automatically by "terraform init". +# This file is maintained automatically by "tofu init". # Manual edits may be lost in future updates. -provider "registry.terraform.io/bpg/proxmox" { +provider "registry.opentofu.org/bpg/proxmox" { version = "0.33.0" constraints = "0.33.0" hashes = [ @@ -23,21 +23,19 @@ provider "registry.terraform.io/bpg/proxmox" { ] } -provider "registry.terraform.io/hashicorp/random" { - version = "3.5.1" +provider "registry.opentofu.org/hashicorp/random" { + version = "3.6.0" hashes = [ - "h1:IL9mSatmwov+e0+++YX2V6uel+dV6bn+fC/cnGDK3Ck=", - "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64", - "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d", - "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831", - "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3", - "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f", - "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b", - "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2", - "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865", - "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03", - "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602", - "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014", + "h1:6QMZ6JACl+V2t8daN5GTlw22EtG7nhc3BbkbJDw2a5M=", + "zh:486a1c921eab5c51a480f2eb0ad85173f207c9b7bb215f3893e58bc38d3b7c75", + "zh:6901b3afa4607d1e31934ba91ed2625215ada42b3518c3a9adeeac7a5f656dc3", + "zh:7e93752c9de710e417191353ad1a41b5a60432ab7ef4f8b556bf248297ec5e23", + "zh:c795d3d319e8ee7be972746b935963b7e772a6a14080261a35c03915c1f9ccb2", + "zh:cd4f8bcaf332828d1736c73874549c25e427737f136173c7b61e2df3db50e5d9", + "zh:e0103eb2e280989c3d9ffda5d6b413e8f583be21bc1d5754c6e9ca87ecc1c44a", + "zh:f4fbec2510322d5b7ad584a92436b5dbd0f2e897a3ec538932af59e245a4c8e4", + "zh:f5418842afd4aa7676e2456e425e8f573cb2b9bffd29bd7de09d91845644ab24", + "zh:f572a26f93d00ec42461ce478678366e570fa4497e2273f9d47f24cdfc4b42b4", + "zh:ff1f07c561a3f7f219b6fee1647a559933b5dd6181753e164c3978fd47a11685", ] } diff --git a/infrastructure/k3s.tf b/infrastructure/k3s.tf new file mode 100644 index 0000000..244a097 --- /dev/null +++ b/infrastructure/k3s.tf @@ -0,0 +1,96 @@ +# proxmox_virtual_environment_vm.devops: +resource "proxmox_virtual_environment_vm" "k3s" { + acpi = true + vm_id = "115" + machine = "q35" + name = "k3s" + node_name = "proxmox" + scsi_hardware = "virtio-scsi-pci" + started = true + tablet_device = false + tags = [] + template = false + + clone { + vm_id = 9999 + } + + agent { + enabled = true + timeout = "15m" + trim = false + type = "virtio" + } + + cpu { + cores = 2 + flags = [] + hotplugged = 0 + numa = false + sockets = 1 + type = "host" + units = 1024 + + } + + disk { + datastore_id = "local" + size = 30 + ssd = true + discard = "ignore" + iothread = true + interface = "scsi0" + } + + initialization { + datastore_id = "local" + interface = "ide2" + + ip_config { + ipv4 { + address = "dhcp" + } + ipv6 { + address = "auto" + } + } + + user_account { + keys = var.virtual_environment_sshkeys + username = "tim" + password = random_password.devops_vm_password.result + } + } + + memory { + dedicated = 4096 + floating = 0 + shared = 0 + } + + network_device { + bridge = "vmbr0" + enabled = true + firewall = false + model = "virtio" + mtu = 0 + rate_limit = 0 + vlan_id = 0 + } + + vga { + enabled = true + memory = 16 + type = "std" + } +} +resource "random_password" "k3s_vm_password" { + length = 16 + override_special = "_%@" + special = true +} + +output "k3s_vm_password" { + value = random_password.k3s_vm_password.result + sensitive = true +} \ No newline at end of file diff --git a/pi-hole/main.tf b/pi-hole/main.tf new file mode 100644 index 0000000..e69de29 diff --git a/pi-hole/resources.tf b/pi-hole/resources.tf new file mode 100644 index 0000000..e69de29 diff --git a/pi-hole/variables.tf b/pi-hole/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/pi-hole/versions.tf b/pi-hole/versions.tf new file mode 100644 index 0000000..e69de29