diff --git a/infrastructure/nixos-cloud-init/README.md b/infrastructure/nixos-cloud-init/README.md new file mode 100644 index 0000000..f2b880b --- /dev/null +++ b/infrastructure/nixos-cloud-init/README.md @@ -0,0 +1,18 @@ +# NixOS Cloud Init image + +## Create image zma.zst +``` +nix run github:nix-community/nixos-generators -- -f proxmox -c configuration.nix +``` + +## Update to proxmox +``` +scp /nix/store/jvwxp7agny9979fglf76s0ca9m2h6950-proxmox-nixos-cloud-init/vzdump-qemu-nixos-cloud-init.vma.zst root@192.168.1.206:/var/lib/vz/dump +``` + +## Init template +``` +qmrestore /var/lib/vz/dump/vzdump-qemu-nixos-cloud-init.vma.zst 9000 --unique true + +qm template 9000 +``` diff --git a/infrastructure/nixos-cloud-init/configuration.nix b/infrastructure/nixos-cloud-init/configuration.nix new file mode 100644 index 0000000..dfc0c50 --- /dev/null +++ b/infrastructure/nixos-cloud-init/configuration.nix @@ -0,0 +1,9 @@ +{ + proxmox = { + filenameSuffix = "nixos-cloud-init"; + + cloudInit = { + enable = true; + }; + }; +} diff --git a/infrastructure/proxmox/.terraform.lock.hcl b/infrastructure/proxmox/.terraform.lock.hcl new file mode 100644 index 0000000..978a610 --- /dev/null +++ b/infrastructure/proxmox/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/telmate/proxmox" { + version = "3.0.2-rc01" + constraints = "3.0.2-rc01" + hashes = [ + "h1:571ROPuTMC0w5lr9hbUXi7NVLsG3SpmZxXXZx8cAT+Q=", + "zh:34d264243a4513f4e30c01fb37cc6a3e592d7823dfd182c5edfb170ac7b7de3a", + "zh:544428311ad20fbb3ad2cd854e893bbf036023cb57c3acc5093d141976dac670", + "zh:5c2396b328edee8de7ac144c15a6b7e668e81063699bc8c110d7c39fb8da70e9", + "zh:5ca8e33476ad06a0259071120a59477e8f107f30c1178ea7b9f6cafe1a461ade", + "zh:5ea56eb8275edc754a01a0180750e9c939cd997d3a50659617770211f4337da9", + "zh:9dd3482df6bbe00a4a6152be3567b6c08d35c3644a327a1f5ac30fd95ccd449f", + "zh:a76075fafadcc94a825151aff169bae4e0c05e3c7717e16dcdcf16ffa61a0780", + "zh:b1d95f97b22f671db762f7adf428b409e6736c078bcf267d8391985b8847d6e3", + "zh:cc94255cd1b18e6a341c15089015c457c8c639c25c426b07f278d5ea9850b3b5", + "zh:ce991103cb69b0b3e275127e3ab92c88bb3b6b0f4e5a2cb082aeaef70a7f7d61", + "zh:d24838bce87b38e12544a1329f5ad30e2be045968e639a3f4ddd5c84aa648e04", + "zh:e106ebd4eea8d62d62e62f261a262febc615e17466b54ac18f7e65c7e79e0008", + "zh:e254ca76c95e6e92da973b7bddc36bfa0a1e31d7c7e758ef4b01315db969388b", + "zh:f1d1d5f4c39267cacebe0ab7e9e06caf9692707f3b5369685541b65bc8b840ce", + ] +} diff --git a/infrastructure/proxmox/.terraform/modules/modules.json b/infrastructure/proxmox/.terraform/modules/modules.json new file mode 100644 index 0000000..a525777 --- /dev/null +++ b/infrastructure/proxmox/.terraform/modules/modules.json @@ -0,0 +1 @@ +{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"nixos_vm","Source":"./modules/nixos-vm","Dir":"modules/nixos-vm"},{"Key":"sandbox_vm","Source":"./modules/nixos-vm","Dir":"modules/nixos-vm"}]} \ No newline at end of file diff --git a/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/LICENSE b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/LICENSE new file mode 100644 index 0000000..57395f1 --- /dev/null +++ b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/README.md b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/README.md new file mode 100644 index 0000000..eb7c72c --- /dev/null +++ b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/README.md @@ -0,0 +1,51 @@ +[![Build Status](https://travis-ci.com/Telmate/terraform-provider-proxmox.svg?branch=master)](https://travis-ci.com/Telmate/terraform-provider-proxmox) + +# Terraform provider plugin for Proxmox + +This repository provides a Terraform provider for +the [Proxmox virtualization platform](https://pve.proxmox.com/pve-docs/) and exposes Terraform resources to provision +QEMU VMs and LXC Containers. + +## Getting Started + +In order to get started, use [the documentation included in this repository](docs/index.md). The documentation contains +a list of the options for the provider. Moreover, there are some guides available how to combine options and start +specific VMs. + +## Quick Start + +Follow this [install guide](docs/guides/installation.md) to install the plugin. + +## Known Limitations + +* `proxmox_vm_qemu`.`disk`.`size` attribute does not match what is displayed in the Proxmox UI. +* Updates to `proxmox_vm_qemu` resources almost always result as a failed task within the Proxmox UI. This appears to be + harmless and the desired configuration changes do get applied. +* When using the `proxmox_lxc` resource, the provider will crash unless `rootfs` is defined. +* When using the Network Boot mode (PXE), a valid NIC must be defined for the VM, and the boot order must specify network first. + +## Contributing + +When contributing, please also add documentation to help other users. + +### Debugging the provider + +Debugging is available for this provider through the Terraform Plugin SDK versions 2.0.0. Therefore, the plugin can be +started with the debugging flag `--debug`. + +For example (using [delve](https://github.com/go-delve/delve) as Debugger): + +```bash +dlv exec --headless ./terraform-provider-my-provider -- --debug +``` + +For more information about debugging a provider please +see: [Debugger-Based Debugging](https://www.terraform.io/docs/extend/debugging.html#debugger-based-debugging) + +## Useful links + +* [Proxmox](https://www.proxmox.com/en/) +* [Proxmox documentation](https://pve.proxmox.com/pve-docs/) +* [Terraform](https://www.terraform.io/) +* [Terraform documentation](https://www.terraform.io/docs/index.html) +* [Recommended ISO builder](https://github.com/Telmate/terraform-ubuntu-proxmox-iso) diff --git a/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/terraform-provider-proxmox_v3.0.2-rc01 b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/terraform-provider-proxmox_v3.0.2-rc01 new file mode 100755 index 0000000..cd85f95 Binary files /dev/null and b/infrastructure/proxmox/.terraform/providers/registry.opentofu.org/telmate/proxmox/3.0.2-rc01/linux_amd64/terraform-provider-proxmox_v3.0.2-rc01 differ diff --git a/infrastructure/proxmox/main.tf b/infrastructure/proxmox/main.tf new file mode 100644 index 0000000..ca08aca --- /dev/null +++ b/infrastructure/proxmox/main.tf @@ -0,0 +1,13 @@ +module "sandbox_vm" { + source = "./modules/nixos-vm" + + vmid = 123 + name = "sandbox" + target_node = var.pm_node + sshkeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUP7m8jZJiclZGfSje8CeBYFhX10SrdtjYziuChmj1X plasmagoat@macbook-air" + cipassword = "$6$rounds=4096$h9zcOYHvB.sy0Ff/$M4cbXjzqmJZ7xRTl3ILWXrg9PePqNzpv.L7MnvMrhcGieK3hrPniU5YEY2Z5/NC1n4QM7VLRSwyP9g9zdjp67/" + # You can override any default variable here: + # cpu_cores = 4 + # memory = 2048 + # disk_size = "10G" +} diff --git a/infrastructure/proxmox/modules/nixos-vm/main.tf b/infrastructure/proxmox/modules/nixos-vm/main.tf new file mode 100644 index 0000000..d788442 --- /dev/null +++ b/infrastructure/proxmox/modules/nixos-vm/main.tf @@ -0,0 +1,66 @@ +terraform { + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = "3.0.2-rc01" + } + } +} + +resource "proxmox_vm_qemu" "nixos-vm" { + vmid = var.vmid + name = var.name + target_node = var.target_node + agent = var.agent + cpu { + cores = var.cpu_cores + } + memory = var.memory + boot = var.boot # " " #"order=scsi0" # has to be the same as the OS disk of the template + clone_id = var.clone_id + full_clone = var.full_clone + scsihw = var.scsihw + vm_state = var.vm_state + automatic_reboot = var.automatic_reboot + + # Cloud-Init configuration + # cicustom = "vendor=local:snippets/qemu-guest-agent.yml" # /var/lib/vz/snippets/qemu-guest-agent.yml + ciupgrade = var.ciupgrade + ipconfig0 = var.ipconfig0 + skip_ipv6 = var.skip_ipv6 + ciuser = var.ciuser + cipassword = var.cipassword # "Enter123!" + sshkeys = var.sshkeys # "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUP7m8jZJiclZGfSje8CeBYFhX10SrdtjYziuChmj1X plasmagoat@macbook-air" + + # Most cloud-init images require a serial device for their display + serial { + id = 0 + } + + disks { + virtio { + virtio0 { + # We have to specify the disk from our template, else Terraform will think it's not supposed to be there + disk { + storage = var.disk_storage + # The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated + size = var.disk_size + } + } + } + ide { + # Some images require a cloud-init disk on the IDE controller, others on the SCSI or SATA controller + ide1 { + cloudinit { + storage = var.cloudinit_storage + } + } + } + } + + network { + id = 0 + bridge = var.network_bridge + model = var.network_model + } +} diff --git a/infrastructure/proxmox/modules/nixos-vm/outputs.tf b/infrastructure/proxmox/modules/nixos-vm/outputs.tf new file mode 100644 index 0000000..8a79e61 --- /dev/null +++ b/infrastructure/proxmox/modules/nixos-vm/outputs.tf @@ -0,0 +1,9 @@ +output "id" { + description = "Instance VM ID" + value = proxmox_vm_qemu.nixos-vm.id +} + +output "public_ipv4" { + description = "Instance Public IPv4 Address" + value = proxmox_vm_qemu.nixos-vm.default_ipv4_address +} diff --git a/infrastructure/proxmox/modules/nixos-vm/variables.tf b/infrastructure/proxmox/modules/nixos-vm/variables.tf new file mode 100644 index 0000000..97ed3bf --- /dev/null +++ b/infrastructure/proxmox/modules/nixos-vm/variables.tf @@ -0,0 +1,133 @@ +variable "vmid" { + description = "The VM ID of the Proxmox VM." + type = number +} + +variable "name" { + description = "The name of the Proxmox VM." + type = string +} + +variable "target_node" { + description = "The Proxmox node to provision the VM on." + type = string +} + +variable "agent" { + description = "Enable QEMU Guest Agent (1 for enabled, 0 for disabled)." + type = number + default = 1 +} + +variable "cpu_cores" { + description = "Number of CPU cores for the VM." + type = number + default = 2 +} + +variable "memory" { + description = "Memory in MB for the VM." + type = number + default = 1024 +} + +variable "boot" { + description = "Boot order for the VM (e.g., 'order=scsi0')." + type = string + default = " " # Proxmox expects a space for default if not specified +} + +variable "clone_id" { + description = "The VM ID of the template to clone from." + type = number + default = 9000 +} + +variable "full_clone" { + description = "Whether to perform a full clone or linked clone." + type = bool + default = true +} + +variable "scsihw" { + description = "SCSI controller hardware type." + type = string + default = "virtio-scsi-single" +} + +variable "vm_state" { + description = "Desired state of the VM ('running', 'stopped', etc.)." + type = string + default = "running" +} + +variable "automatic_reboot" { + description = "Automatically reboot the VM on configuration changes." + type = bool + default = true +} + +variable "ciupgrade" { + description = "Upgrade Cloud-Init tools on first boot." + type = bool + default = true +} + +variable "ipconfig0" { + description = "Cloud-Init IP configuration for network interface 0." + type = string + default = "ip=dhcp" +} + +variable "skip_ipv6" { + description = "Skip IPv6 configuration for Cloud-Init." + type = bool + default = true +} + +variable "ciuser" { + description = "Cloud-Init user for the VM." + type = string + default = "root" +} + +variable "cipassword" { + description = "Cloud-Init password for the VM." + type = string + default = "Enter123!" +} + +variable "sshkeys" { + description = "Public SSH key(s) to be added to the VM." + type = string +} + +variable "disk_storage" { + description = "Storage for the primary OS disk." + type = string + default = "pv1" +} + +variable "disk_size" { + description = "Size of the primary OS disk (e.g., '5G')." + type = string + default = "5G" +} + +variable "cloudinit_storage" { + description = "Storage for the Cloud-Init disk." + type = string + default = "local-lvm" +} + +variable "network_bridge" { + description = "Bridge for the network interface." + type = string + default = "vmbr0" +} + +variable "network_model" { + description = "Model for the network interface." + type = string + default = "virtio" +} diff --git a/infrastructure/proxmox/providers.tf b/infrastructure/proxmox/providers.tf new file mode 100644 index 0000000..07ff31b --- /dev/null +++ b/infrastructure/proxmox/providers.tf @@ -0,0 +1,6 @@ +provider "proxmox" { + pm_tls_insecure = true + pm_api_url = var.pm_api_url + pm_api_token_id = var.pm_api_token_id + pm_api_token_secret = var.pm_api_token_secret +} diff --git a/infrastructure/proxmox/sandbox.tf b/infrastructure/proxmox/sandbox.tf new file mode 100644 index 0000000..899f911 --- /dev/null +++ b/infrastructure/proxmox/sandbox.tf @@ -0,0 +1,58 @@ +# resource "proxmox_vm_qemu" "sandbox" { +# vmid = 123 +# name = "sandbox" +# target_node = var.pm_node +# agent = 1 +# cpu { +# cores = 2 +# } +# memory = 1024 +# boot = " " #"order=scsi0" # has to be the same as the OS disk of the template +# clone_id = 9000 +# full_clone = true +# scsihw = "virtio-scsi-single" +# vm_state = "running" +# automatic_reboot = true + +# # Cloud-Init configuration +# # cicustom = "vendor=local:snippets/qemu-guest-agent.yml" # /var/lib/vz/snippets/qemu-guest-agent.yml +# ciupgrade = true +# ipconfig0 = "ip=dhcp" +# skip_ipv6 = true +# ciuser = "root" +# # ci pasword doesn't seem to work with nix +# # cipassword = "Enter123!" +# sshkeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUP7m8jZJiclZGfSje8CeBYFhX10SrdtjYziuChmj1X plasmagoat@macbook-air" + +# # Most cloud-init images require a serial device for their display +# serial { +# id = 0 +# } + +# disks { +# virtio { +# virtio0 { +# # We have to specify the disk from our template, else Terraform will think it's not supposed to be there +# disk { +# storage = "pv1" +# # The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated +# size = "5G" +# } +# } +# } +# ide { +# # Some images require a cloud-init disk on the IDE controller, others on the SCSI or SATA controller +# ide1 { +# cloudinit { +# storage = "local-lvm" +# } +# } +# } +# } + +# network { +# id = 0 +# bridge = "vmbr0" +# model = "virtio" +# } +# } diff --git a/infrastructure/proxmox/terraform.tfstate b/infrastructure/proxmox/terraform.tfstate new file mode 100644 index 0000000..9b4fec3 --- /dev/null +++ b/infrastructure/proxmox/terraform.tfstate @@ -0,0 +1 @@ +{"version":4,"terraform_version":"1.9.1","serial":16,"lineage":"c76b2921-285f-1904-f2ab-e6a410d16442","outputs":{},"resources":[{"module":"module.sandbox_vm","mode":"managed","type":"proxmox_vm_qemu","name":"nixos-vm","provider":"provider[\"registry.opentofu.org/telmate/proxmox\"]","instances":[{"schema_version":0,"attributes":{"additional_wait":5,"agent":1,"agent_timeout":90,"args":"","automatic_reboot":true,"balloon":0,"bios":"seabios","boot":" ","bootdisk":"","ci_wait":null,"cicustom":null,"cipassword":"$6$rounds=4096$h9zcOYHvB.sy0Ff/$M4cbXjzqmJZ7xRTl3ILWXrg9PePqNzpv.L7MnvMrhcGieK3hrPniU5YEY2Z5/NC1n4QM7VLRSwyP9g9zdjp67/","ciupgrade":true,"ciuser":"root","clone":null,"clone_id":9000,"clone_wait":10,"cores":0,"cpu":[{"affinity":"","cores":2,"flags":[],"limit":0,"numa":false,"sockets":1,"type":"host","units":0,"vcores":0}],"cpu_type":"","current_node":"proxmox-01","default_ipv4_address":"192.168.1.228","default_ipv6_address":"","define_connection_info":true,"desc":"Managed by Terraform.","disk":[],"disks":[{"ide":[{"ide0":[],"ide1":[{"cdrom":[],"cloudinit":[{"storage":"local-lvm"}],"disk":[],"ignore":false,"passthrough":[]}],"ide2":[],"ide3":[]}],"sata":[],"scsi":[],"virtio":[{"virtio0":[{"cdrom":[],"disk":[{"asyncio":"","backup":true,"cache":"","discard":false,"format":"raw","id":0,"iops_r_burst":0,"iops_r_burst_length":0,"iops_r_concurrent":0,"iops_wr_burst":0,"iops_wr_burst_length":0,"iops_wr_concurrent":0,"iothread":false,"linked_disk_id":-1,"mbps_r_burst":0,"mbps_r_concurrent":0,"mbps_wr_burst":0,"mbps_wr_concurrent":0,"readonly":false,"replicate":false,"serial":"","size":"5G","storage":"pv1","wwn":""}],"ignore":false,"passthrough":[]}],"virtio1":[],"virtio10":[],"virtio11":[],"virtio12":[],"virtio13":[],"virtio14":[],"virtio15":[],"virtio2":[],"virtio3":[],"virtio4":[],"virtio5":[],"virtio6":[],"virtio7":[],"virtio8":[],"virtio9":[]}]}],"efidisk":[],"force_create":false,"force_recreate_on_change_of":null,"full_clone":true,"hagroup":"","hastate":"","hostpci":[],"hotplug":"network,disk,usb","id":"proxmox-01/qemu/123","ipconfig0":"ip=dhcp","ipconfig1":null,"ipconfig10":null,"ipconfig11":null,"ipconfig12":null,"ipconfig13":null,"ipconfig14":null,"ipconfig15":null,"ipconfig2":null,"ipconfig3":null,"ipconfig4":null,"ipconfig5":null,"ipconfig6":null,"ipconfig7":null,"ipconfig8":null,"ipconfig9":null,"kvm":true,"linked_vmid":0,"machine":"","memory":1024,"name":"sandbox","nameserver":null,"network":[{"bridge":"vmbr0","firewall":false,"id":0,"link_down":false,"macaddr":"bc:24:11:46:6c:00","model":"virtio","mtu":0,"queues":0,"rate":0,"tag":0}],"numa":false,"onboot":false,"os_network_config":null,"os_type":null,"pci":[],"pcis":[],"pool":"","protection":false,"pxe":null,"qemu_os":"l26","reboot_required":false,"scsihw":"virtio-scsi-single","searchdomain":null,"serial":[{"id":0,"type":"socket"}],"skip_ipv4":false,"skip_ipv6":true,"smbios":[{"family":"","manufacturer":"","product":"","serial":"","sku":"","uuid":"5ae92cdd-a036-4602-af8c-358197f958d9","version":""}],"sockets":0,"ssh_forward_ip":null,"ssh_host":"192.168.1.228","ssh_port":"22","ssh_private_key":null,"ssh_user":null,"sshkeys":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUP7m8jZJiclZGfSje8CeBYFhX10SrdtjYziuChmj1X plasmagoat@macbook-air\n","startup":"","tablet":true,"tags":"","target_node":"proxmox-01","target_nodes":null,"timeouts":null,"tpm_state":[],"unused_disk":[],"usb":[],"usbs":[],"vcpus":0,"vga":[],"vm_state":"running","vmid":123},"sensitive_attributes":[[{"type":"get_attr","value":"ssh_private_key"}],[{"type":"get_attr","value":"cipassword"}]],"private":"eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19"}]}],"check_results":null} diff --git a/infrastructure/proxmox/terraform.tfstate.backup b/infrastructure/proxmox/terraform.tfstate.backup new file mode 100644 index 0000000..848b2ff --- /dev/null +++ b/infrastructure/proxmox/terraform.tfstate.backup @@ -0,0 +1 @@ +{"version":4,"terraform_version":"1.9.1","serial":15,"lineage":"c76b2921-285f-1904-f2ab-e6a410d16442","outputs":{},"resources":[{"module":"module.sandbox_vm","mode":"managed","type":"proxmox_vm_qemu","name":"nixos-vm","provider":"provider[\"registry.opentofu.org/telmate/proxmox\"]","instances":[{"schema_version":0,"attributes":{"additional_wait":5,"agent":1,"agent_timeout":90,"args":"","automatic_reboot":true,"balloon":0,"bios":"seabios","boot":" ","bootdisk":"","ci_wait":null,"cicustom":null,"cipassword":"","ciupgrade":true,"ciuser":"root","clone":null,"clone_id":9000,"clone_wait":10,"cores":0,"cpu":[{"affinity":"","cores":2,"flags":[],"limit":0,"numa":false,"sockets":1,"type":"host","units":0,"vcores":0}],"cpu_type":"","current_node":"proxmox-01","default_ipv4_address":"192.168.1.228","default_ipv6_address":"2a05:f6c7:2030:0:be24:11ff:fe46:6c00","define_connection_info":true,"desc":"Managed by Terraform.","disk":[],"disks":[{"ide":[{"ide0":[],"ide1":[{"cdrom":[],"cloudinit":[{"storage":"local-lvm"}],"disk":[],"ignore":false,"passthrough":[]}],"ide2":[],"ide3":[]}],"sata":[],"scsi":[],"virtio":[{"virtio0":[{"cdrom":[],"disk":[{"asyncio":"","backup":true,"cache":"","discard":false,"format":"raw","id":0,"iops_r_burst":0,"iops_r_burst_length":0,"iops_r_concurrent":0,"iops_wr_burst":0,"iops_wr_burst_length":0,"iops_wr_concurrent":0,"iothread":false,"linked_disk_id":-1,"mbps_r_burst":0,"mbps_r_concurrent":0,"mbps_wr_burst":0,"mbps_wr_concurrent":0,"readonly":false,"replicate":false,"serial":"","size":"5G","storage":"pv1","wwn":""}],"ignore":false,"passthrough":[]}],"virtio1":[],"virtio10":[],"virtio11":[],"virtio12":[],"virtio13":[],"virtio14":[],"virtio15":[],"virtio2":[],"virtio3":[],"virtio4":[],"virtio5":[],"virtio6":[],"virtio7":[],"virtio8":[],"virtio9":[]}]}],"efidisk":[],"force_create":false,"force_recreate_on_change_of":null,"full_clone":true,"hagroup":"","hastate":"","hostpci":[],"hotplug":"network,disk,usb","id":"proxmox-01/qemu/123","ipconfig0":"ip=dhcp","ipconfig1":null,"ipconfig10":null,"ipconfig11":null,"ipconfig12":null,"ipconfig13":null,"ipconfig14":null,"ipconfig15":null,"ipconfig2":null,"ipconfig3":null,"ipconfig4":null,"ipconfig5":null,"ipconfig6":null,"ipconfig7":null,"ipconfig8":null,"ipconfig9":null,"kvm":true,"linked_vmid":0,"machine":"","memory":1024,"name":"sandbox","nameserver":null,"network":[{"bridge":"vmbr0","firewall":false,"id":0,"link_down":false,"macaddr":"bc:24:11:46:6c:00","model":"virtio","mtu":0,"queues":0,"rate":0,"tag":0}],"numa":false,"onboot":false,"os_network_config":null,"os_type":null,"pci":[],"pcis":[],"pool":"","protection":false,"pxe":null,"qemu_os":"l26","reboot_required":false,"scsihw":"virtio-scsi-single","searchdomain":null,"serial":[{"id":0,"type":"socket"}],"skip_ipv4":false,"skip_ipv6":true,"smbios":[{"family":"","manufacturer":"","product":"","serial":"","sku":"","uuid":"5ae92cdd-a036-4602-af8c-358197f958d9","version":""}],"sockets":0,"ssh_forward_ip":null,"ssh_host":"192.168.1.228","ssh_port":"22","ssh_private_key":null,"ssh_user":null,"sshkeys":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUP7m8jZJiclZGfSje8CeBYFhX10SrdtjYziuChmj1X plasmagoat@macbook-air\n","startup":"","tablet":true,"tags":"","target_node":"proxmox-01","target_nodes":null,"timeouts":null,"tpm_state":[],"unused_disk":[],"usb":[],"usbs":[],"vcpus":0,"vga":[],"vm_state":"running","vmid":123},"sensitive_attributes":[[{"type":"get_attr","value":"ssh_private_key"}],[{"type":"get_attr","value":"cipassword"}]],"private":"eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19"}]}],"check_results":null} diff --git a/infrastructure/proxmox/terraform.tfvars b/infrastructure/proxmox/terraform.tfvars new file mode 100644 index 0000000..32006a4 --- /dev/null +++ b/infrastructure/proxmox/terraform.tfvars @@ -0,0 +1,3 @@ + +pm_node = "proxmox-01" +# nixos_template_id = 9100 diff --git a/infrastructure/proxmox/variables.tf b/infrastructure/proxmox/variables.tf new file mode 100644 index 0000000..daf8c39 --- /dev/null +++ b/infrastructure/proxmox/variables.tf @@ -0,0 +1,19 @@ +variable "pm_api_url" { + description = "The URL of the Proxmox API (e.g., https://192.168.1.10:8006/api2/json)" + type = string +} + +variable "pm_node" { + description = "The Proxmox node name where VMs will be deployed (e.g., 'pve')" + type = string +} + +variable "pm_api_token_id" { + description = "Proxmox API token ID" + type = string +} + +variable "pm_api_token_secret" { + description = "Proxmox API token secret" + type = string +} diff --git a/infrastructure/proxmox/versions.tf b/infrastructure/proxmox/versions.tf new file mode 100644 index 0000000..a2341f9 --- /dev/null +++ b/infrastructure/proxmox/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = "3.0.2-rc01" + } + } +}