-
Notifications
You must be signed in to change notification settings - Fork 0
/
debian.pkr.hcl
277 lines (229 loc) · 5.91 KB
/
debian.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
packer {
required_plugins {
name = {
version = "1.1.8"
source = "github.com/hashicorp/proxmox"
}
}
}
variable "bios_type" {
type = string
}
variable "boot_wait" {
type = string
default = "10s"
}
variable "bridge_name" {
type = string
}
variable "vlan_tag" {
type = string
default = "20"
}
variable "bridge_firewall" {
type = bool
default = false
}
variable "cloud_init" {
type = bool
default = false
}
variable "cpu_type" {
type = string
}
variable "disk_discard" {
type = bool
}
variable "disk_format" {
type = string
default = "qcow2"
}
variable "disk_size" {
type = string
default = "8G"
}
variable "disk_type" {
type = string
default = "scsi"
}
variable "machine_default_type" {
type = string
default = "Default (i440fx)"
}
variable "nb_core" {
type = number
default = 1
}
variable "nb_cpu" {
type = number
default = 1
}
variable "nb_ram" {
type = number
default = 4096
}
variable "network_model" {
type = string
default = "virtio"
}
variable "numa" {
type = bool
default = true
}
variable "io_thread" {
type = bool
default = false
}
variable "os_type" {
type = string
default = "l26"
}
variable "proxmox_api_token_id" {
type = string
default = ""
}
variable "proxmox_api_token_secret" {
type = string
sensitive = true
}
variable "proxmox_api_url" {
type = string
}
variable "proxmox_node" {
type = string
}
variable "qemu_agent_activation" {
type = bool
default = true
}
variable "scsi_controller_type" {
type = string
}
variable "ssh_handshake_attempts" {
type = number
default = 6
}
variable "ssh_timeout" {
type = string
default = "15m"
}
variable "ssh_username" {
type = string
default = "debian"
}
variable "ssh_password" {
type = string
default = "zxcv1234"
}
variable "storage_pool" {
type = string
}
variable "tags" {
type = string
default = "template"
}
variable "vm_id" {
type = number
default = 9000
}
variable "vm_info" {
type = string
default = "Debian 12 Packer Template"
}
variable "vm_name" {
type = string
default = "debian12-template"
}
variable "iso_storage_pool" {
type = string
default = "local"
}
variable "iso_url" {
type = string
}
variable "iso_checksum" {
type = string
}
source "proxmox-iso" "debian12" {
bios = "${var.bios_type}"
boot_wait = "${var.boot_wait}"
cloud_init = "${var.cloud_init}"
cloud_init_storage_pool = "${var.storage_pool}"
communicator = "ssh"
cores = "${var.nb_core}"
cpu_type = "${var.cpu_type}"
insecure_skip_tls_verify = true
iso_url = "${var.iso_url}"
iso_checksum = "${var.iso_checksum}"
iso_storage_pool = "${var.iso_storage_pool}"
memory = "${var.nb_ram}"
ssh_password = "${var.ssh_password}"
ssh_timeout = "${var.ssh_timeout}"
ssh_username = "${var.ssh_username}"
node = "${var.proxmox_node}"
os = "${var.os_type}"
proxmox_url = "${var.proxmox_api_url}"
qemu_agent = "${var.qemu_agent_activation}"
scsi_controller = "${var.scsi_controller_type}"
sockets = "${var.nb_cpu}"
tags = "${var.tags}"
token = "${var.proxmox_api_token_secret}"
unmount_iso = true
username = "${var.proxmox_api_token_id}"
vm_id = "${var.vm_id}"
vm_name = "${var.vm_name}"
numa = "${var.numa}"
template_name = "${var.vm_name}"
boot_command = [
"<wait><esc><wait>",
"install <wait>",
" preseed/url=https://raw.githubusercontent.com/HanidaM/devops-boilerplates/main/http/preseed.cfg <wait>",
"debian-installer=en_US.UTF-8 <wait>",
"auto <wait>",
"locale=en_US.UTF-8 <wait>",
"kbd-chooser/method=us <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
# static network config
"netcfg/disable_autoconfig=true <wait>",
"netcfg/use_autoconfig=false <wait>",
"netcfg/get_ipaddress=192.168.1.10 <wait>",
"netcfg/get_netmask=255.255.255.0 <wait>",
"netcfg/get_gateway=192.168.1.1 <wait>",
"netcfg/get_nameservers=8.8.8.8 <wait>",
"netcfg/confirm_static=true <wait>",
"netcfg/get_hostname=${var.vm_name} <wait>",
"netcfg/get_domain= <wait>",
"fb=false <wait>",
"debconf/frontend=noninteractive <wait>",
"console-setup/ask_detect=false <wait>",
"console-keymaps-at/keymap=us <wait>",
"grub-installer/bootdev=default <wait>",
"<enter><wait>",
]
disks {
discard = "${var.disk_discard}"
disk_size = "${var.disk_size}"
format = "${var.disk_format}"
io_thread = "${var.io_thread}"
storage_pool = "${var.storage_pool}"
type = "${var.disk_type}"
}
network_adapters {
bridge = "${var.bridge_name}"
vlan_tag = "${var.vlan_tag}"
firewall = "${var.bridge_firewall}"
model = "${var.network_model}"
}
}
build {
sources = ["source.proxmox-iso.debian12"]
provisioner "shell" {
inline = [
"sudo apt-get update -y",
"sudo apt-get install qemu-guest-agent cloud-init -y",
"sudo systemctl start qemu-guest-agent",
"sudo systemctl start cloud-init",
"echo 'QEMU Guest Agent and cloud-init installation and setup completed '"
]
}
}