Skip to content

Commit

Permalink
Merge pull request #13 from stuttgart-things/feature/issue-1/vmTest-p…
Browse files Browse the repository at this point in the history
…ipeline

Go to tests dir
  • Loading branch information
anacalva authored Mar 25, 2024
2 parents 3e0e4f9 + 901eae8 commit ef85a94
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 63 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/vm-creation-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
def write_file(testVars, output_file_name):
environment = Environment(loader=FileSystemLoader("tests/templates/"))
template = environment.get_template("module.tpl")
filename = "main.tf"
filename = "terraform.tfvars"
content = template.render(
name = output_file_name,
vm_count = random.choice(testVars['vm_count']),
Expand Down Expand Up @@ -77,8 +77,8 @@ jobs:
- name: Upload main.tf file for job 2
uses: actions/upload-artifact@v4
with:
name: terraform_main
path: main.tf
name: terraform_vars
path: terraform.tfvars

test-terraform-apply:
needs: build-terraform-file
Expand All @@ -93,7 +93,7 @@ jobs:
- name: Download main
uses: actions/download-artifact@v4
with:
name: terraform_main
name: terraform_vars

- run: |
terraform init
Expand Down
59 changes: 59 additions & 0 deletions tests/templates/module copy.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module "proxmox-vm" {
source = "git::https://github.com/stuttgart-things/proxmox-vm.git"
#source = "../../repos/proxmox-vm"
pve_api_url = var.pve_api_url
pve_api_user = var.pve_api_user
pve_api_password = var.pve_api_password
pve_api_tls_verify = var.pve_api_tls_verify
pve_cluster_node = "sthings-pve1"
pve_datastore = "{{ pve_datastore }}"
pve_folder_path = "stuttgart-things"
pve_network = "vmbr103"
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_ssh_user = var.vm_ssh_user
vm_ssh_password = var.vm_ssh_password
}

output "ip" {
value = module.proxmox-vm.ip
}

output "mac" {
value = module.proxmox-vm.mac
}

output "id" {
value = module.proxmox-vm.id
}


variable "pve_api_url" {
description = "url of proxmox api"
}

variable "pve_api_user" {
description = "username of proxmox api user"
}

variable "pve_api_password" {
description = "password of proxmox api user"
}

variable "vm_ssh_user" {
description = "username of proxmox api user"
}

variable "vm_ssh_password" {
description = "password of proxmox api user"
}

variable "pve_api_tls_verify" {
description = "proxmox API disable check if cert is valid"
}
70 changes: 11 additions & 59 deletions tests/templates/module.tpl
Original file line number Diff line number Diff line change
@@ -1,59 +1,11 @@
module "proxmox-vm" {
source = "git::https://github.com/stuttgart-things/proxmox-vm.git"
#source = "../../repos/proxmox-vm"
pve_api_url = var.pve_api_url
pve_api_user = var.pve_api_user
pve_api_password = var.pve_api_password
pve_api_tls_verify = var.pve_api_tls_verify
pve_cluster_node = "sthings-pve1"
pve_datastore = "{{ pve_datastore }}"
pve_folder_path = "stuttgart-things"
pve_network = "vmbr103"
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_ssh_user = var.vm_ssh_user
vm_ssh_password = var.vm_ssh_password
}

output "ip" {
value = module.proxmox-vm.ip
}

output "mac" {
value = module.proxmox-vm.mac
}

output "id" {
value = module.proxmox-vm.id
}


variable "pve_api_url" {
description = "url of proxmox api"
}

variable "pve_api_user" {
description = "username of proxmox api user"
}

variable "pve_api_password" {
description = "password of proxmox api user"
}

variable "vm_ssh_user" {
description = "username of proxmox api user"
}

variable "vm_ssh_password" {
description = "password of proxmox api user"
}

variable "pve_api_tls_verify" {
description = "proxmox API disable check if cert is valid"
}
pve_cluster_node = "sthings-pve1"
pve_datastore = "{{ pve_datastore }}"
pve_folder_path = "stuttgart-things"
pve_network = "vmbr103"
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"

0 comments on commit ef85a94

Please sign in to comment.