Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions home-lab/terraform/lxc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ module "immich_lxc" {
}

module "bitwarden_lxc" {
source = "../../terraform-modules/proxmox/lxc"
source = "../../terraform-modules/proxmox/lxc"

node_name = "proxmox"
node_name = "proxmox"

lxc_hostname = "vaultwarden"
# vm_id = 114
Expand All @@ -157,7 +157,7 @@ module "bitwarden_lxc" {
lxc_memory = 1024
# lxc_memory_swap = 512

lxc_password = var.default_password
lxc_password = var.default_password
ssh_public_keys = local.default_ssh_public_key

lxc_features_nesting = true
Expand Down
2 changes: 1 addition & 1 deletion home-lab/terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
# https://github.com/bpg/terraform-provider-proxmox
proxmox = {
source = "bpg/proxmox"
version = "0.86.0"
version = "0.89.1"
}

# https://github.com/Telmate/terraform-provider-proxmox
Expand Down
127 changes: 127 additions & 0 deletions home-lab/terraform/vm.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
module "opnsense" {
source = "../../terraform-modules/proxmox/vm"

proxmox_node = "proxmox"

vm_name = "opnsense"
vm_description = "Managed by Terraform"

vm_cpu_type = "host"
vm_cores = 2
vm_sockets = 1

vm_memory = 4096

vm_scsihw = "virtio-scsi-single"

vm_display = {
type = "serial0"
}

vm_disks = [
{
backup = true
datastore_id = "local"
interface = "ide2"
replicate = true
size = 2
},
{
aio = "io_uring"
backup = true
cache = "writeback"
datastore_id = "nvme4tb"
size = 30
iothread = true
replicate = true
}
]

vm_network_devices = [
{
bridge = "vmbr0"
enable_firewall = false
},
{
bridge = "vmbr1"
enable_firewall = false
}
]

operating_system_type = "l26"
vm_machine_type = "q35"

vm_tags = ["firewall"]
}


module "windows11" {
source = "../../terraform-modules/proxmox/vm"

proxmox_node = "proxmox"

vm_name = "Win11"
vm_description = "Managed by Terraform"

vm_cpu_flags = []
# vm_cpu_units = 0
vm_memory = 4096

vm_scsihw = "virtio-scsi-single"
vm_enable_qemu_agent = true
vm_bios_type = "ovmf" # UEFI

vm_display = {
type = "std"
}

vm_disks = [
# CD/DVD ide0 virtio-win
{
backup = true
datastore_id = "local"
interface = "ide0"
replicate = true
# The size is around 0.7GB but the tf proxmox provider
# (bpg/proxmox:v0.89.1) requires a minimum of 1GB
# I have to manually update the tfstate
size = 1
},
# CD/DVD ide2 Win11.iso
{
backup = true
datastore_id = "local"
interface = "ide2"
replicate = true
size = 7
},
# Hard disk scsi0
{
backup = true
datastore_id = "local-lvm"
interface = "scsi0"
replicate = true
size = 64
iothread = true
},
]

vm_network_devices = [
{
bridge = "vmbr0"
enable_firewall = true
},
]

operating_system_type = "win11"
vm_machine_type = "pc-q35-10.0+pve1"

efi_disk = {
datastore_id = "local-lvm"
file_format = "raw"
pre_enrolled_keys = true
type = "4m"
}

vm_tags = ["windows"]
}
11 changes: 11 additions & 0 deletions terraform-modules/proxmox/vm/examples/00-simple-vm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module "this" {
source = "../../"

proxmox_node = "proxmox"

vm_name = "terraform-provider-proxmox-ubuntu-vm"
vm_description = "Managed by Terraform"
vm_tags = ["ubuntu"]

enable_network = false
}
23 changes: 23 additions & 0 deletions terraform-modules/proxmox/vm/examples/00-simple-vm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "proxmox_api_url" {
description = "Proxmox API URL"
type = string
default = "https://pve01.cloud.local:8006/api2/json"
}

variable "proxmox_api_token_id" {
description = "Proxmox API token ID"
type = string
sensitive = true
}

variable "proxmox_api_token_secret" {
description = "Proxmox API token secret"
type = string
sensitive = true
}

variable "proxmox_tls_insecure" {
description = "Skip TLS verification for Proxmox API"
type = bool
default = true
}
18 changes: 18 additions & 0 deletions terraform-modules/proxmox/vm/examples/00-simple-vm/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_version = ">= 1.0"

required_providers {
# https://github.com/bpg/terraform-provider-proxmox
proxmox = {
source = "bpg/proxmox"
version = "0.89.1"
}
}
}

provider "proxmox" {
endpoint = "https://proxmox.internal.local:8006"
insecure = var.proxmox_tls_insecure

api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
}
17 changes: 17 additions & 0 deletions terraform-modules/proxmox/vm/examples/01-clone-vm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module "this" {
source = "../../"

proxmox_node = "proxmox"

vm_name = "terraform-ubuntu-clone"
vm_description = "Managed by Terraform"
vm_tags = ["ubuntu"]

clone_vm = true
clone_vm_target = {
vm_id = 901
full = true
}

vm_enable_qemu_agent = true
}
24 changes: 24 additions & 0 deletions terraform-modules/proxmox/vm/examples/01-clone-vm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Proxmox provider
variable "proxmox_api_url" {
description = "Proxmox API URL"
type = string
default = "https://pve01.cloud.local:8006/api2/json"
}

variable "proxmox_api_token_id" {
description = "Proxmox API token ID"
type = string
sensitive = true
}

variable "proxmox_api_token_secret" {
description = "Proxmox API token secret"
type = string
sensitive = true
}

variable "proxmox_tls_insecure" {
description = "Skip TLS verification for Proxmox API"
type = bool
default = true
}
18 changes: 18 additions & 0 deletions terraform-modules/proxmox/vm/examples/01-clone-vm/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_version = ">= 1.0"

required_providers {
# https://github.com/bpg/terraform-provider-proxmox
proxmox = {
source = "bpg/proxmox"
version = "0.89.1"
}
}
}

provider "proxmox" {
endpoint = "https://proxmox.internal.local:8006"
insecure = var.proxmox_tls_insecure

api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
}
Loading