Add ssh_private_key/ssh_public_key variables to create-template-vm module

This commit is contained in:
Viktor Barzin 2026-02-07 13:19:15 +00:00
parent 5a8147b115
commit c0b7fd10d5
No known key found for this signature in database
GPG key ID: 0EB088298288D958

View file

@ -19,6 +19,14 @@ variable "containerd_config_update_command" {
description = "Command to execute to update containerd config.toml; e.g add mirror" description = "Command to execute to update containerd config.toml; e.g add mirror"
} }
variable "is_k8s_template" { type = bool } variable "is_k8s_template" { type = bool }
variable "ssh_private_key" {
type = string
default = ""
}
variable "ssh_public_key" {
type = string
default = ""
}
variable "provision_cmds" { variable "provision_cmds" {
type = list(string) type = list(string)
default = [] default = []
@ -30,7 +38,7 @@ resource "null_resource" "create_template_remote" {
type = "ssh" type = "ssh"
user = var.proxmox_user user = var.proxmox_user
host = var.proxmox_host host = var.proxmox_host
private_key = file("~/.ssh/id_ed25519") private_key = var.ssh_private_key
} }
# Commands executed *on Proxmox host* # Commands executed *on Proxmox host*
@ -61,7 +69,7 @@ resource "null_resource" "upload_cloud_init" {
type = "ssh" type = "ssh"
host = var.proxmox_host host = var.proxmox_host
user = var.proxmox_user user = var.proxmox_user
private_key = file("~/.ssh/id_ed25519") private_key = var.ssh_private_key
} }
provisioner "remote-exec" { provisioner "remote-exec" {
@ -72,7 +80,7 @@ resource "null_resource" "upload_cloud_init" {
destination = "/var/lib/vz/snippets/${var.snippet_name}" destination = "/var/lib/vz/snippets/${var.snippet_name}"
content = templatefile("${path.module}/cloud_init.yaml", { content = templatefile("${path.module}/cloud_init.yaml", {
is_k8s_template = var.is_k8s_template, is_k8s_template = var.is_k8s_template,
authorized_ssh_key = file("~/.ssh/id_ed25519.pub"), authorized_ssh_key = var.ssh_public_key,
passwd = var.user_passwd, passwd = var.user_passwd,
provision_cmds = var.provision_cmds, provision_cmds = var.provision_cmds,
k8s_join_command = var.k8s_join_command, k8s_join_command = var.k8s_join_command,