-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkali.pkr.hcl
163 lines (152 loc) · 3.61 KB
/
kali.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
packer {
required_plugins {
# see https://github.com/hashicorp/packer-plugin-qemu
qemu = {
version = "1.0.9"
source = "github.com/hashicorp/qemu"
}
# see https://github.com/hashicorp/packer-plugin-proxmox
proxmox = {
version = "1.1.3"
source = "github.com/hashicorp/proxmox"
}
}
}
variable "version" {
type = string
}
variable "vagrant_box" {
type = string
}
variable "disk_size" {
type = string
default = 25 * 1024
}
variable "iso_url" {
type = string
default = "https://cdimage.kali.org/kali-2023.3/kali-linux-2023.3-installer-netinst-amd64.iso"
}
variable "iso_checksum" {
type = string
default = "sha256:0b0f5560c21bcc1ee2b1fef2d8e21dca99cc6efa938a47108bbba63bec499779"
}
variable "proxmox_node" {
type = string
default = env("PROXMOX_NODE")
}
source "qemu" "kali-amd64" {
accelerator = "kvm"
machine_type = "q35"
efi_boot = true
cpus = 2
memory = 2 * 1024
qemuargs = [
["-cpu", "host"],
]
headless = true
net_device = "virtio-net"
http_directory = "."
format = "qcow2"
disk_size = var.disk_size
disk_interface = "virtio-scsi"
disk_cache = "unsafe"
disk_discard = "unmap"
iso_url = var.iso_url
iso_checksum = var.iso_checksum
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "60m"
boot_wait = "10s"
boot_command = [
"c<wait>",
"linux /install.amd/vmlinuz",
" auto=true",
" url={{.HTTPIP}}:{{.HTTPPort}}/preseed.txt",
" hostname=vagrant",
" domain=home",
" net.ifnames=0",
" BOOT_DEBUG=2",
" DEBCONF_DEBUG=5",
"<enter><wait5s>",
"initrd /install.amd/initrd.gz",
"<enter><wait5s>",
"boot",
"<enter><wait5s>",
]
shutdown_command = "echo vagrant | sudo -S poweroff"
}
source "proxmox-iso" "kali-amd64" {
template_name = "template-kali-${var.version}"
template_description = "See https://github.com/rgl/kali-vagrant"
insecure_skip_tls_verify = true
node = var.proxmox_node
machine = "q35"
bios = "ovmf"
efi_config {
efi_storage_pool = "local-lvm"
}
cpu_type = "host"
cores = 2
memory = 2 * 1024
vga {
type = "qxl"
memory = 16
}
network_adapters {
model = "virtio"
bridge = "vmbr0"
}
scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "${var.disk_size}M"
storage_pool = "local-lvm"
}
iso_storage_pool = "local"
iso_url = var.iso_url
iso_checksum = var.iso_checksum
unmount_iso = true
os = "l26"
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "60m"
http_directory = "."
boot_wait = "30s"
boot_command = [
"c<wait>",
"linux /install.amd/vmlinuz",
" auto=true",
" url={{.HTTPIP}}:{{.HTTPPort}}/preseed.txt",
" hostname=vagrant",
" domain=home",
" net.ifnames=0",
" BOOT_DEBUG=2",
" DEBCONF_DEBUG=5",
"<enter><wait5s>",
"initrd /install.amd/initrd.gz",
"<enter><wait5s>",
"boot",
"<enter><wait5s>",
]
}
build {
sources = [
"source.qemu.kali-amd64",
"source.proxmox-iso.kali-amd64",
]
provisioner "shell" {
expect_disconnect = true
execute_command = "echo vagrant | sudo -S {{ .Vars }} bash {{ .Path }}"
scripts = [
"provision-guest-additions.sh",
"provision.sh"
]
}
post-processor "vagrant" {
only = [
"qemu.kali-amd64",
]
output = var.vagrant_box
vagrantfile_template = "Vagrantfile.template"
}
}