From 0518ee5343b3354c4fac29fb5dd851d840be4ddb Mon Sep 17 00:00:00 2001 From: Matthew McKinnon Date: Sat, 26 Oct 2024 22:29:05 +1000 Subject: [PATCH] Initial Commit --- .gitignore | 5 + .terraform.lock.hcl | 70 ++++++++++ cloudinit.tf | 109 +++++++++++++++ files/cloud_init.cloud_config | 19 +++ main.backup | 240 ++++++++++++++++++++++++++++++++++ provider.tf | 56 ++++++++ terraform.auto.tfvars.example | 6 + 7 files changed, 505 insertions(+) create mode 100755 .gitignore create mode 100644 .terraform.lock.hcl create mode 100644 cloudinit.tf create mode 100644 files/cloud_init.cloud_config create mode 100755 main.backup create mode 100755 provider.tf create mode 100755 terraform.auto.tfvars.example diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..f97d9a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +terraform.auto.tfvars +.terraform +tokens.txt +terraform.tfstate* + diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 0000000..d683d23 --- /dev/null +++ b/.terraform.lock.hcl @@ -0,0 +1,70 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/hashicorp/local" { + version = "2.5.2" + hashes = [ + "h1:6lS+5A/4WFAqY3/RHWFRBSiFVLPRjvLaUgxPQvjXLHU=", + "zh:25b95b76ceaa62b5c95f6de2fa6e6242edbf51e7fc6c057b7f7101aa4081f64f", + "zh:3c974fdf6b42ca6f93309cf50951f345bfc5726ec6013b8832bcd3be0eb3429e", + "zh:5de843bf6d903f5cca97ce1061e2e06b6441985c68d013eabd738a9e4b828278", + "zh:86beead37c7b4f149a54d2ae633c99ff92159c748acea93ff0f3603d6b4c9f4f", + "zh:8e52e81d3dc50c3f79305d257da7fde7af634fed65e6ab5b8e214166784a720e", + "zh:9882f444c087c69559873b2d72eec406a40ede21acb5ac334d6563bf3a2387df", + "zh:a4484193d110da4a06c7bffc44cc6b61d3b5e881cd51df2a83fdda1a36ea25d2", + "zh:a53342426d173e29d8ee3106cb68abecdf4be301a3f6589e4e8d42015befa7da", + "zh:d25ef2aef6a9004363fc6db80305d30673fc1f7dd0b980d41d863b12dacd382a", + "zh:fa2d522fb323e2121f65b79709fd596514b293d816a1d969af8f72d108888e4c", + ] +} + +provider "registry.opentofu.org/hashicorp/null" { + version = "3.2.3" + hashes = [ + "h1:LF8arSzHfhbyQSFtTMTYEqCM34klzrbAQBJMHYCs9d8=", + "zh:1d57d25084effd3fdfd902eca00020b34b1fb020253b84d7dd471301606015ac", + "zh:65b7f9799b88464d9c2ec529713b7f52ea744275b61a8dc86cdedab1b2dcb933", + "zh:80d3e9c95b7b4ae7c54005cd127cae82e5c53d2b7023ef24c147337bac9dadd9", + "zh:841b60c07683e4bf456799ccd718896fdafdcc2c49252ae09967f2e74d8c8a03", + "zh:8fa1c592a9c78222e35713c6edb3f1f818a4c6f3524a30a209f0a7e919827b68", + "zh:bb795cc1429e09466840c09d39a28edf1db5070b1ec76822fc1173906a264572", + "zh:da1784818a89bea29dfe660632f0060a7a843e4e564d74435fbeca002b0f7d2a", + "zh:f409bf21b1cdaa6dac47cd79806f3d93f67e9507fe4dbf33b0165335f53bc2e1", + "zh:fbea7a1ff84b430ba9594698e93196d81d03e4036de3d1cafccb2a96d5b38581", + "zh:fbf0c84663a7e85881388d7d71ac862184f05fbf2d17ecf76bc5d3d7503ea260", + ] +} + +provider "registry.opentofu.org/hashicorp/template" { + version = "2.2.0" + hashes = [ + "h1:tdS0otiAtvUV8uLJWJNfcqOPo3llj7FyRzExw6X1srY=", + "zh:374c28bafc43cd65e578cb209efc9eee4c1cec7618f451528e928db98059e8c8", + "zh:6a2982e70fbc2ab2668d624c648ef2eb32243c1a1185246b03991a7a21326db9", + "zh:af83169c21bb13f141510a349e1f70cf7d893247a269bd71cad74dd22f1df0f5", + "zh:b81a5bedc91a1a81b938c393247248d6c3d1bd8ea685541f9c858908c0afb6b3", + "zh:de15486244af2d29d44d510d647cd6e0b1408e89952261013c572b7c9bfd744b", + ] +} + +provider "registry.opentofu.org/telmate/proxmox" { + version = "3.0.1-rc4" + constraints = "3.0.1-rc4" + hashes = [ + "h1:wTzPTXWFxydIF6yUIkBnGQRQs0A1eWJadqyQ7EJHeAU=", + "zh:1070aff02aebeadf130368b0082e76d976f61464b3bb29c1c5a7866bb14c7380", + "zh:3cd96c232a12cf3bbb0e874508e5ff14116ef347d60db20db17ad87bb161ee22", + "zh:4f75954f3e68159ed969e3eac27485166103058eff3f99186d805816c6f8eb66", + "zh:55572fd22f7c62813a691fe0d017b2a57a34f3b4e1c40af6c2197731878ebf84", + "zh:6536402b2eff0a754ff975c39318c3c0b47dfa2dc4461d34a8c55ba493288d9f", + "zh:735f4283286cb78fe28b4ad001771c460f1963ee640e027467eb199d80a6c257", + "zh:90a675455c5812d90acbf44bfee347c2318b13565c68bcf64b452dbe6c2a629a", + "zh:9bbfe89d3f0997a26d7636d5c2d7244beccf92371d17073583299b1b74e1ab9c", + "zh:9ed8ecb50c4ed8555ffe1544325de07db678e2877f7c4637fbfaf02d5f004100", + "zh:b1e362ebd234aa82a38ffcfa4e74295e8a23811edff8af88f79372ba18ef0918", + "zh:c652faede363a91ad3a148cdd1b3d9c3ab8bac1b94d92ce89eb6e1ddadc99cc1", + "zh:d803958e5e465095cc0d5741abf0abd80b5fd3d1c076b40880a136e737bb06d0", + "zh:fa12bd372e39c8ac6295503f88884f328971834e109fcc015322fc9ab5fe858f", + "zh:fb7abe461d36f9868a0a6728320e482ecd54e047c2876dce85d5c2143eba3b8f", + ] +} diff --git a/cloudinit.tf b/cloudinit.tf new file mode 100644 index 0000000..3a38ca7 --- /dev/null +++ b/cloudinit.tf @@ -0,0 +1,109 @@ +resource "null_resource" "cloud_init_deb" { + connection { + type = "ssh" + user = "root" + private_key = file("~/.ssh/pve2.comprofix.xyz") + host = "pve2.comprofix.xyz" + agent = true + } + + provisioner "file" { + source = "files/cloud_init.cloud_config" + destination = "/var/lib/vz/snippets/cloud_init_deb.yml" + } +} + + + +resource "proxmox_vm_qemu" "dev" { + + # VM General Settings + target_node = "pve" + vmid = "500" + name = "dev" + desc = "Dev Server" + + + # VM Advanced General Settings + onboot = true + scsihw = "virtio-scsi-single" + + # VM OS Settings + clone = "debian-12-generic-amd64" + clone_wait = 120 + timeouts { + create = "1h" + delete = "1h" + } + + # VM System Settings + agent = 1 + machine = "q35" + qemu_os = "l26" + + # VM CPU Settings + cores = 4 + sockets = 1 + cpu = "kvm64" + bios = "ovmf" + + startup = "" + + + # VM Memory Settings + memory = 16384 + + # VM Network Settings + network { + bridge = "vmbr0" + model = "virtio" + tag = "10" + } + + efidisk { + efitype = "4m" + storage = "local-zfs" + } + + disks { + ide { + ide2 { + cdrom { + passthrough = false + } + } + ide3 { + cloudinit { + storage = "local-zfs" + } + } + } + scsi { + scsi0 { + disk { + size = 20 + storage = "local-zfs" + } + } + } + } + + # VM Cloud-Init Settings + os_type = "cloud-init" + cicustom = "vendor=local:snippets/cloud_init_deb.yml" + #cloudinit_cdrom_storage = "local-zfs" + + # (Optional) IP Address and Gateway + ipconfig0 = "ip=10.10.10.22/24,gw=10.10.10.1" + nameserver = "10.10.10.1" + + # (Optional) Default User + ciuser = "${var.ci_user}" + cipassword = "${var.ci_password}" + + # (Optional) Add your SSH Public KEY + sshkeys = <