From 86a9c170338705023fd28372a0f7b1cafe76c035 Mon Sep 17 00:00:00 2001 From: Florian Paul Azim Hoberg Date: Fri, 30 Aug 2024 19:39:32 +0200 Subject: [PATCH] feature: Add shell script for further automation --- create_vm.sh | 10 ++++++++++ variables.tf | 6 ++++++ virtual_machines.tf | 6 +++--- vmcount.txt | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100755 create_vm.sh create mode 100644 variables.tf create mode 100644 vmcount.txt diff --git a/create_vm.sh b/create_vm.sh new file mode 100755 index 0000000..3d36a55 --- /dev/null +++ b/create_vm.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +PROXMOX_NODE=$(/bin/proxlb -b) +PROXMOX_VM_ID=$( vmcount.txt + +terraform apply -var="hostname=managed-vm$PROXMOX_VM_ID.boxybsd.com" -var="node=$PROXMOX_NODE" diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..190c304 --- /dev/null +++ b/variables.tf @@ -0,0 +1,6 @@ +variable "hostname" { + type = string +} +variable "node" { + type = string +} diff --git a/virtual_machines.tf b/virtual_machines.tf index 032c707..db6c613 100644 --- a/virtual_machines.tf +++ b/virtual_machines.tf @@ -1,8 +1,8 @@ -resource "proxmox_virtual_environment_vm" "managed-vm33" { - name = "managed-vm33.boxybsd.com" +resource "proxmox_virtual_environment_vm" "main" { + name = var.hostname description = "Managed by Terraform" tags = ["terraform"] - node_name = "virt01" + node_name = var.node cpu { cores = 1 diff --git a/vmcount.txt b/vmcount.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/vmcount.txt @@ -0,0 +1 @@ +1