Skip to content

Commit

Permalink
Expanded variables for pipeline workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
anacalva committed Apr 10, 2024
1 parent 1f2ae31 commit 142739f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/vm-creation-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/templates/module.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
21 changes: 19 additions & 2 deletions tests/test_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- v3700
pve_network:
- vmbr101
- vmbr102
- vmbr103
- vmbr104
vm_disk_size:
- 20G
- 32G
- 64G
- 96G
- 128G
- 196G
- 256G
vm_memory:
- 1024
- 2048
- 4096
- 8192
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 142739f

Please sign in to comment.