rewritten files such its more abstracted

This commit is contained in:
Petar Cubela
2025-09-21 23:35:16 +02:00
parent cc6cb8c9da
commit fe593b1190
8 changed files with 320 additions and 8 deletions

View File

@@ -1,9 +1,48 @@
# Source the Cloud Init Config file
#data "template_file" "cloud_init_fed42_ipa" {
# template = "${file("${path.module}/files/cloud_init_fedora42_ipa.cloud_config")}"
#
# vars = {
# ssh_key = var.petar_ssh_public_key
# hostname = var.hostname_ipa
# domain = var.domain
# }
#}
# Create a local copy of the file, to transfer to Proxmox
resource "local_file" "cloud_init_fed42_ipa" {
#content = data.template_file.cloud_init_deb10_vm-01.rendered
content = templatefile("${var.working_directory}/cloud-inits/cloud_init_fedora42_ipa.cloud_config.tftpl", { ssh_key = var.petar_ssh_public_key, hostname = var.hostname_ipa , domain = var.domain })
filename = "${path.module}/files/user_data_cloud_init_fedora42_ipa.cfg"
}
# Transfer the file to the Proxmox Host
resource "null_resource" "cloud_init_fed42_ipa" {
connection {
type = "ssh"
user = var.prov_user
private_key = var.petar_ssh_private_key
host = var.proxmox_host
}
provisioner "file" {
source = local_file.cloud_init_fed42_ipa.filename
destination = "/var/lib/vz/snippets/user_data_cloud_init_fedora42_ipa.yml"
}
}
resource "proxmox_vm_qemu" "vm-freeipa" {
name = "ipa"
name = var.hostname_ipa
depends_on = [
null_resource.cloud_init_fed42_ipa
]
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = "pve"
target_node = "neo"
# The template name to clone this vm from
clone = "temp-fedora-38"
@@ -11,8 +50,10 @@ resource "proxmox_vm_qemu" "vm-freeipa" {
# Activate QEMU agent for this VM
agent = 1
#pool = linux
os_type = "cloud-init"
vmid = 111
vmid = 1000
vm_state = "running"
cpu {
@@ -52,7 +93,7 @@ resource "proxmox_vm_qemu" "vm-freeipa" {
bridge = "vmbr0"
macaddr = "bc:24:11:de:cb:30"
}
nameserver = "9.9.9.9,10.11.12.254"
nameserver = ""
onboot = true
boot = "order=scsi0"
@@ -60,9 +101,11 @@ resource "proxmox_vm_qemu" "vm-freeipa" {
# Setup the ip address using cloud-init.
# Keep in mind to use the CIDR notation for the ip.
ipconfig0 = "ip=10.11.12.65/24,gw=10.11.12.254"
ciuser = "sbxadmin"
cicustom = "vendor=local:snippets/qemu-guest-agent.yml,user=local:snippets/cloud_init_fedora_vm_ipa.yml" # /var/lib/vz/snippets/qemu-guest-agent.yml
#ipconfig0 = "ip=10.11.12.65/24,gw=10.11.12.254"
ipconfig0 = "ip6=auto"
ciuser = var.prov_user
#cicustom = "vendor=local:snippets/qemu-guest-agent.yml,user=local:snippets/cloud_init_fedora_vm_ipa.yml" # /var/lib/vz/snippets/qemu-guest-agent.yml
cicustom = "user=local:snippets/user_data_cloud_init_fedora42_ipa.yml"
ciupgrade = true
sshkeys = var.petar_ssh_public_key