From 09e3cd62b7ee959aa26c59617966cf08c3e02bd8 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Mon, 14 Jul 2025 19:56:23 -0400 Subject: [PATCH] chore(tests): allow different node / storage names in "example tests" (#2042) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Signed-off-by: MacherelR <64424331+MacherelR@users.noreply.github.com> Co-authored-by: MacherelR <64424331+MacherelR@users.noreply.github.com> --- example/resource_virtual_environment_container.tf | 6 +++--- .../resource_virtual_environment_download_file.tf | 14 ++------------ example/resource_virtual_environment_vm.tf | 4 ++-- example/variables.tf | 12 ++++++++++++ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/example/resource_virtual_environment_container.tf b/example/resource_virtual_environment_container.tf index d7135beb..c244f306 100644 --- a/example/resource_virtual_environment_container.tf +++ b/example/resource_virtual_environment_container.tf @@ -4,13 +4,13 @@ resource "proxmox_virtual_environment_container" "example_template" { start_on_boot = "true" disk { - datastore_id = "local-lvm" + datastore_id = var.virtual_environment_storage size = 4 } mount_point { // volume mount - volume = "local-lvm" + volume = var.virtual_environment_storage size = "4G" path = "mnt/local" } @@ -66,7 +66,7 @@ resource "proxmox_virtual_environment_container" "example_template" { resource "proxmox_virtual_environment_container" "example" { disk { - datastore_id = "local-lvm" + datastore_id = var.virtual_environment_storage } clone { diff --git a/example/resource_virtual_environment_download_file.tf b/example/resource_virtual_environment_download_file.tf index 895fcb52..2ddeba6b 100644 --- a/example/resource_virtual_environment_download_file.tf +++ b/example/resource_virtual_environment_download_file.tf @@ -3,7 +3,7 @@ resource "proxmox_virtual_environment_download_file" "release_20250610_ubuntu_24_noble_lxc_img" { content_type = "vztmpl" datastore_id = "local" - node_name = "pve" + node_name = var.virtual_environment_node_name url = var.release_20250610_ubuntu_24_noble_lxc_img_url checksum = var.release_20250610_ubuntu_24_noble_lxc_img_checksum checksum_algorithm = "sha256" @@ -12,20 +12,10 @@ resource "proxmox_virtual_environment_download_file" "release_20250610_ubuntu_24 } resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_qcow2_img" { - content_type = "iso" - datastore_id = "local" - file_name = "debian-12-generic-amd64.img" - node_name = "pve" - url = var.latest_debian_12_bookworm_qcow2_img_url - overwrite = true - overwrite_unmanaged = true -} - -resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_qcow2" { content_type = "import" datastore_id = "local" file_name = "debian-12-generic-amd64.qcow2" - node_name = "pve" + node_name = var.virtual_environment_node_name url = var.latest_debian_12_bookworm_qcow2_img_url overwrite = true overwrite_unmanaged = true diff --git a/example/resource_virtual_environment_vm.tf b/example/resource_virtual_environment_vm.tf index 4da07249..9340f732 100644 --- a/example/resource_virtual_environment_vm.tf +++ b/example/resource_virtual_environment_vm.tf @@ -1,5 +1,5 @@ locals { - datastore_id = "local-lvm" + datastore_id = var.virtual_environment_storage } resource "proxmox_virtual_environment_vm" "example_template" { @@ -232,7 +232,7 @@ resource "proxmox_virtual_environment_vm" "data_vm" { datastore_id = local.datastore_id interface = "scsi0" size = 8 - import_from = proxmox_virtual_environment_download_file.latest_debian_12_bookworm_qcow2.id + import_from = proxmox_virtual_environment_download_file.latest_debian_12_bookworm_qcow2_img.id } disk { diff --git a/example/variables.tf b/example/variables.tf index 968bd191..04f3aa61 100644 --- a/example/variables.tf +++ b/example/variables.tf @@ -13,6 +13,18 @@ variable "virtual_environment_ssh_username" { description = "The username for the Proxmox Virtual Environment API" } +variable "virtual_environment_node_name" { + description = "Name of the Proxmox node" + type = string + default = "pve" +} + +variable "virtual_environment_storage" { + description = "Name of the Proxmox storage" + type = string + default = "local-lvm" +} + variable "latest_debian_12_bookworm_qcow2_img_url" { type = string description = "The URL for the latest Debian 12 Bookworm qcow2 image"