infra
This commit is contained in:
parent
5a409b3014
commit
0347f4d325
18 changed files with 441 additions and 0 deletions
66
infrastructure/proxmox/modules/nixos-vm/main.tf
Normal file
66
infrastructure/proxmox/modules/nixos-vm/main.tf
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
9
infrastructure/proxmox/modules/nixos-vm/outputs.tf
Normal file
9
infrastructure/proxmox/modules/nixos-vm/outputs.tf
Normal file
|
|
@ -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
|
||||
}
|
||||
133
infrastructure/proxmox/modules/nixos-vm/variables.tf
Normal file
133
infrastructure/proxmox/modules/nixos-vm/variables.tf
Normal file
|
|
@ -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"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue