diff --git a/main.tf b/main.tf index 55cf191..93c9328 100644 --- a/main.tf +++ b/main.tf @@ -20,6 +20,7 @@ terraform { source = "techBeck03/guacamole" version = "~> 1.4.1" } + } backend "kubernetes" { secret_suffix = "tfstate" @@ -396,10 +397,16 @@ EOT ] } +resource "random_integer" "proxmox_node" { + min=1 + max=2 + count=var.num_routers +} + resource "proxmox_vm_qemu" "vyos_router" { - count = 3 + count = var.num_routers name = "vyos-${count.index + 1}" #count.index starts at 0, so + 1 means this VM will be named test-vm-1 in proxmox - target_node = var.proxmox_host + target_node = "${var.proxmox_host_prefix}${random_integer.proxmox_node[count.index].result}" clone = var.vyos_template_name agent = 1 os_type = "cloud-init" diff --git a/vars.tf b/vars.tf index 5d03007..2068e60 100644 --- a/vars.tf +++ b/vars.tf @@ -65,8 +65,12 @@ variable "ssh_key" { EOT } -variable "proxmox_host" { - default = "px1" +variable "proxmox_host_prefix" { + default = "px" +} + +variable "num_routers" { + default = "3" } variable "template_name" {