From 8e818a27bbf40f0d14bd2d237817599ad5d8b9c4 Mon Sep 17 00:00:00 2001 From: Ana Calva Date: Mon, 25 Mar 2024 11:20:51 +0100 Subject: [PATCH 1/2] Go to tests dir --- .github/workflows/vm-creation-terraform.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/vm-creation-terraform.yaml b/.github/workflows/vm-creation-terraform.yaml index 5e264d7..7457349 100644 --- a/.github/workflows/vm-creation-terraform.yaml +++ b/.github/workflows/vm-creation-terraform.yaml @@ -89,6 +89,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + + - name: Go to tests dir + shell: bash + run: | + cd tests - name: Download main uses: actions/download-artifact@v4 From 901eae8fd60eb6a6ee91ade7f5dde7a28f45ef6b Mon Sep 17 00:00:00 2001 From: Ana Calva Date: Mon, 25 Mar 2024 11:32:29 +0100 Subject: [PATCH 2/2] create tfvars --- .github/workflows/vm-creation-terraform.yaml | 13 ++-- tests/templates/module copy.tpl | 59 +++++++++++++++++ tests/templates/module.tpl | 70 +++----------------- 3 files changed, 74 insertions(+), 68 deletions(-) create mode 100644 tests/templates/module copy.tpl diff --git a/.github/workflows/vm-creation-terraform.yaml b/.github/workflows/vm-creation-terraform.yaml index 7457349..e3251cb 100644 --- a/.github/workflows/vm-creation-terraform.yaml +++ b/.github/workflows/vm-creation-terraform.yaml @@ -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']), @@ -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 @@ -89,16 +89,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Go to tests dir - shell: bash - run: | - cd tests - name: Download main uses: actions/download-artifact@v4 with: - name: terraform_main + name: terraform_vars - run: | terraform init diff --git a/tests/templates/module copy.tpl b/tests/templates/module copy.tpl new file mode 100644 index 0000000..aeaed30 --- /dev/null +++ b/tests/templates/module copy.tpl @@ -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" +} \ No newline at end of file diff --git a/tests/templates/module.tpl b/tests/templates/module.tpl index aeaed30..b4339d1 100644 --- a/tests/templates/module.tpl +++ b/tests/templates/module.tpl @@ -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" -} \ No newline at end of file +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"