-
Notifications
You must be signed in to change notification settings - Fork 0
/
platforms.pkr.hcl
59 lines (53 loc) · 1.84 KB
/
platforms.pkr.hcl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
source "null" "ssh" {}
# common upload builder for all virtual environments
build {
name = "veupload"
dynamic "source" {
labels = ["null.ssh"]
for_each = var.vehost_sources
content {
name = source.value.name
ssh_host = source.value.ssh_host
ssh_username = source.value.ssh_username
ssh_private_key_file = source.value.ssh_private_key_file
}
}
provisioner "file" {
name = "uploadimage"
source = "output/${var.target}/packer-kvm.img"
destination = "/tmp/packer-kvm.img"
}
}
build {
name = "proxmox"
dynamic "source" {
labels = ["null.ssh"]
for_each = var.vehost_sources
content {
name = source.value.name
ssh_host = source.value.ssh_host
ssh_username = source.value.ssh_username
ssh_private_key_file = source.value.ssh_private_key_file
}
}
provisioner "shell" {
name = "createvm"
scripts = ["./scripts/pvecreate.sh"]
environment_vars = [
"VMNAME=${lower(var.target)}",
"VMID=${var.proxmox_settings[source.name].vmid}",
"VMMEM=${var.proxmox_settings[source.name].memory}",
"VMCORES=${var.proxmox_settings[source.name].cpu}",
"VMNET=${var.proxmox_settings[source.name].net}",
"VMSCSIHW=${var.proxmox_settings[source.name].scsihw}",
"VMSTORE=${var.proxmox_settings[source.name].imagestorage}",
"VMIMGPATH=/tmp/packer-kvm.img",
"VMOSTYPE=${var.proxmox_settings[source.name].ostype}",
"VMBALLOON=${var.proxmox_settings[source.name].balloon}",
"VMQEMUAGENT=${var.proxmox_settings[source.name].qemuagent}",
"VMCACHE=${var.proxmox_settings[source.name].cache}",
"VMDISCARD=${var.proxmox_settings[source.name].discard}",
"VMDISKFORMAT=${var.proxmox_settings[source.name].diskformat}"
]
}
}