Files
tofu-pve-lnx/vm_freeipa_clients.tf
2025-09-24 10:56:47 +02:00

100 lines
2.7 KiB
HCL

# Create a local copy of the file, to transfer to Proxmox
resource "local_file" "cloud_init_fed42_ipa_clients" {
content = templatefile("${var.working_directory}/cloud-inits/cloud_init_fedora42_ipa_clients.cloud_config.tftpl", { ssh_key = var.petar_ssh_public_key, hostname = var.hostname_vms[0] , domain = var.domain })
filename = "${path.module}/files/user_data_cloud_init_fedora42_ipa_clients.cfg"
}
# Transfer the file to the Proxmox Host
resource "null_resource" "cloud_init_fed42_ipa_clients" {
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_clients.filename
destination = "/var/lib/vz/snippets/user_data_cloud_init_fedora42_ipa_clients.yml"
}
}
resource "proxmox_vm_qemu" "vm00" {
name = var.hostname_vms[0]
depends_on = [
null_resource.cloud_init_fed42_ipa_clients
]
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = "neo"
# The template name to clone this vm from
clone = "temp-fedora-38"
# Activate QEMU agent for this VM
agent = 1
#pool = linux
os_type = "cloud-init"
vmid = 1100
vm_state = "running"
cpu {
cores = 2
sockets = 1
type = "host"
}
memory = 2048
scsihw = "virtio-scsi-pci"
# Setup the disk
disks {
scsi {
scsi0 {
# We have to specify the disk from our template, else Terraform will think it's not supposed to be there
disk {
storage = "local-lvm"
# The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated
size = "16G"
}
}
}
ide {
# Some images require a cloud-init disk on the IDE controller, others on the SCSI or SATA controller
ide1 {
cloudinit {
storage = "local-lvm"
}
}
}
}
# Setup the network interface and assign a vlan tag: 256
network {
id = 0
model = "virtio"
bridge = "vmbr0"
macaddr = "bc:24:11:de:cb:31"
}
nameserver = var.ipa_ula_addr
onboot = true
boot = "order=scsi0"
tags = "ldap,samba,kerberos,dns,pki"
# 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"
ipconfig0 = "ip6=auto"
ciuser = var.prov_user
cicustom = "user=local:snippets/user_data_cloud_init_fedora42_ipa_clients.yml"
ciupgrade = true
sshkeys = var.petar_ssh_public_key
}