forked from mathianasj/proxmox-ocp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm-template.tf
38 lines (33 loc) · 1.06 KB
/
vm-template.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
resource "proxmox_vm_qemu" "fedora35_template" {
name = "fedora35-template"
target_node = var.template_target_node
agent = 1
oncreate = false
scsihw = "virtio-scsi-pci"
pxe = true
boot = "order=net0"
qemu_os = "l26"
network {
model = "virtio"
bridge = var.template_bridge
}
lifecycle {
ignore_changes = [
disk
]
}
}
resource "null_resource" "fedora35_template_import" {
depends_on = [
local_file.ansible_inventory
]
triggers = {
templatevmid = split("/",proxmox_vm_qemu.fedora35_template.id)[2],
template = proxmox_vm_qemu.fedora35_template.name,
template_url = var.fedora_qcow_url,
template_storage = var.template_storage
}
provisioner "local-exec" {
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i ./ansible/inventory -e vmid=${self.triggers.templatevmid} -e template_url=${self.triggers.template_url} -e template_storage=${self.triggers.template_storage} ./ansible/template/import-template.yaml"
}
}