Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded variables for pipeline workflow #15

Merged
merged 2 commits into from
Apr 10, 2024
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
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(testVars['vm_memory']),
)

# Save template
Expand Down
8 changes: 4 additions & 4 deletions tests/templates/module.tpl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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