mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-12 07:16:51 +00:00
0dff14f4ba
- Use proxmox_virtual_environment_file resource to upload the auto-install ISO via the API. terraform destroy now cleans up both the VM and ISO. - Remove manual upload-to-pve.sh and cleanup-pve-storage.sh scripts. - Commit .terraform.lock.hcl for reproducible CI builds. - Replace iso_file_id variable with iso_local_path and iso_storage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
81 lines
1.3 KiB
Terraform
81 lines
1.3 KiB
Terraform
terraform {
|
|
required_version = ">= 1.5.0"
|
|
required_providers {
|
|
proxmox = {
|
|
source = "bpg/proxmox"
|
|
version = ">= 0.70.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "proxmox" {
|
|
endpoint = var.proxmox_endpoint
|
|
api_token = var.proxmox_api_token
|
|
insecure = var.proxmox_insecure
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_file" "auto_iso" {
|
|
content_type = "iso"
|
|
datastore_id = var.iso_storage
|
|
node_name = var.target_node
|
|
|
|
source_file {
|
|
path = var.iso_local_path
|
|
}
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_vm" "nested_pve" {
|
|
name = var.vm_name
|
|
node_name = var.target_node
|
|
vm_id = var.vm_id
|
|
|
|
machine = "q35"
|
|
bios = "ovmf"
|
|
|
|
cpu {
|
|
type = "host"
|
|
cores = var.cores
|
|
sockets = 1
|
|
}
|
|
|
|
memory {
|
|
dedicated = var.memory
|
|
}
|
|
|
|
efi_disk {
|
|
datastore_id = var.disk_storage
|
|
type = "4m"
|
|
}
|
|
|
|
disk {
|
|
datastore_id = var.disk_storage
|
|
interface = "scsi0"
|
|
size = var.disk_size
|
|
file_format = "raw"
|
|
}
|
|
|
|
cdrom {
|
|
file_id = proxmox_virtual_environment_file.auto_iso.id
|
|
interface = "ide2"
|
|
}
|
|
|
|
network_device {
|
|
bridge = var.network_bridge
|
|
model = "virtio"
|
|
}
|
|
|
|
operating_system {
|
|
type = "l26"
|
|
}
|
|
|
|
agent {
|
|
enabled = true
|
|
}
|
|
|
|
started = true
|
|
|
|
lifecycle {
|
|
ignore_changes = [started, cdrom]
|
|
}
|
|
}
|