-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntu2004.pkr.hcl
82 lines (71 loc) · 2.62 KB
/
ubuntu2004.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
## Dummy source that enables us to run the ansible pre-provisioning.
source "null" "ansible-pre-provisioning" {
communicator = "none"
}
## Run ansible pre-provisioning playbook.
build {
sources = ["source.null.ansible-pre-provisioning"]
provisioner "ansible" {
playbook_file = "${path.root}/playbooks/pre-provisioning.yml"
extra_arguments = [
"--extra-vars",
"user='${var.template_ssh_username}' password='${var.template_ssh_password}' ssh_folder='${var.template_ssh_key_output_folder}' ssh_key_name='${var.template_ssh_key_name}'"
]
}
}
## Define proxmox Ubuntu 20.04 template.
source "proxmox" "ubuntu2004" {
username = "${var.proxmox_username}"
password = "${var.proxmox_password}"
proxmox_url = "${var.proxmox_url}"
insecure_skip_tls_verify = "${var.proxmox_insecure_skip_tls_verify}"
node = "${var.proxmox_node}"
template_name = "${var.template_name}"
template_description = "${var.template_description}"
os = "${var.template_os}"
iso_file = "${var.template_iso_file}"
unmount_iso = "${var.template_unmount_iso}"
memory = "${var.template_memory}"
cores = "${var.template_cores}"
cpu_type = "${var.template_cpu_type}"
scsi_controller = "${var.tempalte_scsi_controller}"
qemu_agent = "${var.template_qemu_agent}"
vga {
type = "${var.template_vga_type}"
memory = "${var.template_vga_memory}"
}
network_adapters {
model = "${var.template_network_model}"
bridge = "${var.template_network_bridge}"
}
disks {
disk_size = "${var.template_disks_disk_size}"
storage_pool = "${var.template_disks_storage_pool}"
storage_pool_type = "${var.template_disks_storage_pool_type}"
type = "${var.template_disks_type}"
}
http_directory = "output/http"
boot_wait = "5s"
boot_command = [
"<esc><wait><esc><wait><f6><wait><esc><wait>",
"<bs><bs><bs><bs><bs>",
"autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ",
"--- <enter>"
]
ssh_timeout = "20m"
ssh_username = "${var.template_ssh_username}"
ssh_password = "${var.template_ssh_password}"
}
# Build proxmox Ubuntu 20.04 template and wait for cloud-init to finish.
build {
sources = ["source.proxmox.ubuntu2004"]
provisioner "shell" {
inline = [
"echo 'Waiting for cloud-init...'",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 1; done"
]
}
provisioner "ansible" {
playbook_file = "${path.root}/playbooks/post-provisioning.yml"
}
}