From 142739fbce63ea4870323bac1eb998948bccd375 Mon Sep 17 00:00:00 2001 From: Ana Calva Date: Wed, 10 Apr 2024 14:02:07 +0200 Subject: [PATCH 1/2] Expanded variables for pipeline workflow --- .github/workflows/vm-creation-terraform.yaml | 3 +++ tests/templates/module.tpl | 6 +++--- tests/test_values.yaml | 21 ++++++++++++++++++-- variables.tf | 5 +++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/vm-creation-terraform.yaml b/.github/workflows/vm-creation-terraform.yaml index 38ac31a..ca23f24 100644 --- a/.github/workflows/vm-creation-terraform.yaml +++ b/.github/workflows/vm-creation-terraform.yaml @@ -52,6 +52,9 @@ jobs: vm_count = random.choice(testVars['vm_count']), vm_num_cpus = random.choice(testVars['vm_num_cpus']), pve_datastore = random.choice(testVars['pve_datastore']), + pve_network = random.choice(testVars['pve_network']), + vm_disk_size = random.choice(testVars['vm_disk_size']), + vm_memory = random.choice(tastVars['vm_memory']), ) # Save template diff --git a/tests/templates/module.tpl b/tests/templates/module.tpl index 1ab1f17..aab4267 100644 --- a/tests/templates/module.tpl +++ b/tests/templates/module.tpl @@ -8,14 +8,14 @@ module "proxmox-vm" { pve_cluster_node = "sthings-pve1" pve_datastore = "{{ pve_datastore }}" pve_folder_path = "stuttgart-things" - pve_network = "vmbr103" + pve_network = "{{ pve_network }}" vm_count = {{ vm_count }} vm_name = "{{ name }}" vm_notes = "vm-info" vm_template = "ubuntu22" vm_num_cpus = "{{ vm_num_cpus }}" - vm_memory = "4096" - vm_disk_size = "32G" + vm_memory = {{ vm_memory }} + vm_disk_size = "{{ vm_disk_size }}" vm_ssh_user = var.vm_ssh_user vm_ssh_password = var.vm_ssh_password } diff --git a/tests/test_values.yaml b/tests/test_values.yaml index cd91ad5..8e3c2b2 100644 --- a/tests/test_values.yaml +++ b/tests/test_values.yaml @@ -8,7 +8,24 @@ vm_num_cpus: # should pick one of them randomly - 2 - 4 - 8 -#vm_name: #E.G. RANDOM NAME W/ LENGHT XY OR PREFIX MAYBE - UP TO YOU BUT THING OF CONSTRAINS LIKE LENGHT OR FORBIDDEN CHARS LIKE _ pve_datastore: # should pick one of them randomly - datastore - - v3700 \ No newline at end of file + - v3700 +pve_network: + - vmbr101 + - vmbr102 + - vmbr103 + - vmbr104 +vm_disk_size: + - 20G + - 32G + - 64G + - 96G + - 128G + - 196G + - 256G +vm_memory: + - 1024 + - 2048 + - 4096 + - 8192 \ No newline at end of file diff --git a/variables.tf b/variables.tf index ef383ac..7948ddc 100644 --- a/variables.tf +++ b/variables.tf @@ -104,6 +104,11 @@ variable "vm_memory" { default = 4096 type = number description = "amount of memory of the vm" + + validation { + condition = contains([1024, 2048, 4096, 8192], var.vm_memory) + error_message = "Valid values for vm_memory are (1024, 2048, 4096, 8192)" + } } variable "vm_disk_size" { From facc863ddefd816da0cb7787f24aaa91bfe0ca86 Mon Sep 17 00:00:00 2001 From: Ana Calva Date: Wed, 10 Apr 2024 14:13:11 +0200 Subject: [PATCH 2/2] Change source --- .github/workflows/vm-creation-terraform.yaml | 2 +- tests/templates/module.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vm-creation-terraform.yaml b/.github/workflows/vm-creation-terraform.yaml index ca23f24..5b25956 100644 --- a/.github/workflows/vm-creation-terraform.yaml +++ b/.github/workflows/vm-creation-terraform.yaml @@ -54,7 +54,7 @@ jobs: pve_datastore = random.choice(testVars['pve_datastore']), pve_network = random.choice(testVars['pve_network']), vm_disk_size = random.choice(testVars['vm_disk_size']), - vm_memory = random.choice(tastVars['vm_memory']), + vm_memory = random.choice(testVars['vm_memory']), ) # Save template diff --git a/tests/templates/module.tpl b/tests/templates/module.tpl index aab4267..64223c5 100644 --- a/tests/templates/module.tpl +++ b/tests/templates/module.tpl @@ -1,5 +1,5 @@ module "proxmox-vm" { - source = "git::https://github.com/stuttgart-things/proxmox-vm.git" + source = "../." pve_api_url = var.pve_api_url pve_api_user = var.pve_api_user pve_api_password = var.pve_api_password