From e0d8f7df3b32ad89001bb346ce993779a0953928 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sat, 11 Oct 2025 17:24:26 +0000 Subject: [PATCH] parameterize ssh keys in create vm module [ci skip] --- main.tf | 4 ++-- modules/create-vm/main.tf | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main.tf b/main.tf index 6089051e..5362613d 100644 --- a/main.tf +++ b/main.tf @@ -180,8 +180,8 @@ module "template-vm" { # vm_name = "pxe-server" # vm_disk_size = 50 # cisnippet_name = local.vm_cloud_init_snippet_name - -# # vm_mac_address = "00:50:56:87:4a:2d" +# bridge = "vmbr0" +# vm_mac_address = "00:50:56:87:4a:2d" # } # module "k8s_master" { diff --git a/modules/create-vm/main.tf b/modules/create-vm/main.tf index c849c680..8191bf20 100644 --- a/modules/create-vm/main.tf +++ b/modules/create-vm/main.tf @@ -20,6 +20,11 @@ variable "vm_mac_address" { default = null } variable "cisnippet_name" { type = string } +variable "ssh_keys" { + type = string + default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDHLhYDfyx237eJgOGVoJRECpUS95+7rEBS9vacsIxtx devvm" +} +variable "bridge" { type = string } resource "proxmox_vm_qemu" "cloudinit-vm" { @@ -36,28 +41,26 @@ resource "proxmox_vm_qemu" "cloudinit-vm" { os_type = "cloud-init" # Cloud-Init configuration + cicustom = "vendor=local:snippets/${var.cisnippet_name}" ciupgrade = true nameserver = "1.1.1.1 8.8.8.8" ipconfig0 = "ip=dhcp,ip6=dhcp" skip_ipv6 = true ciuser = "root" - sshkeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDHLhYDfyx237eJgOGVoJRECpUS95+7rEBS9vacsIxtx vbarzin@gmail.com" + sshkeys = var.ssh_keys searchdomain = "viktorbarzin.lan" onboot = true # start on node boot qemu_os = "l26" - cicustom = "vendor=local:snippets/${var.cisnippet_name}" cpu { cores = var.vm_cpus type = "host" # emulate host cpu } - # Most cloud-init images require a serial device for their display serial { id = 0 } - disks { scsi { scsi0 { @@ -78,10 +81,9 @@ resource "proxmox_vm_qemu" "cloudinit-vm" { } } } - network { id = 0 - bridge = "vmbr0" + bridge = var.bridge model = "e1000" macaddr = var.vm_mac_address }