-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathubuntu-25-04-vbox-amd64.pkr.hcl
More file actions
172 lines (147 loc) · 3.93 KB
/
Copy pathubuntu-25-04-vbox-amd64.pkr.hcl
File metadata and controls
172 lines (147 loc) · 3.93 KB
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
variable "vm_name" {
type = string
default = "uso"
}
variable "guest_os_type" {
type = string
default = "Ubuntu_64"
}
variable "iso_url" {
type = string
default = "https://releases.ubuntu.com/releases/25.04/ubuntu-25.04-desktop-amd64.iso"
}
variable "iso_checksum" {
type = string
default = "sha256:b87366b62eddfbecb60e681ba83299c61884a0d97569abe797695c8861f5dea4"
}
variable "iso_name" {
type = string
default = "ubuntu-25.04-desktop-amd64.iso"
}
variable "cpus" {
type = number
default = 2
}
variable "memsize" {
type = number
default = 2048
}
variable "disk_size" {
type = number
default = 40000
}
variable "ctf_disk_size" {
type = number
default = 10
}
variable "disk_format" {
type = string
default = "ova"
}
variable "username" {
type = string
default = "student"
}
variable "password" {
type = string
default = "student"
}
variable "headless" {
type = bool
default = false
}
variable "img_name" {
type = string
default = "USO"
}
variable "arch" {
type = string
default = "amd64"
}
variable "output_directory" {
type = string
default = "output-amd64"
}
variable "checksum_directory" {
type = string
default = "checksums"
}
packer {
required_plugins {
virtualbox = {
version = "~> 1"
source = "github.com/hashicorp/virtualbox"
}
ansible = {
version = "~> 1"
source = "github.com/hashicorp/ansible"
}
}
}
source "virtualbox-iso" "ubuntu-25-04" {
guest_os_type = var.guest_os_type
iso_url = var.iso_url
iso_checksum = var.iso_checksum
ssh_username = var.username
ssh_password = var.password
ssh_timeout = "180m"
http_content = {
"/user-data" = templatefile("scripts/autoinst/ubuntu-25-04-autoinstall.yml", {
user = {
username = var.username
password = bcrypt(var.password)
}
hostname = var.vm_name
}),
"/meta-data" = ""
}
shutdown_command = "rm -rf ~/.ansible && echo '${var.password}' | sudo -S poweroff"
disk_size = var.disk_size
disk_additional_size = [ var.ctf_disk_size ]
vm_name = "${var.img_name}"
format = var.disk_format
cpus = var.cpus
memory = var.memsize
headless = var.headless
output_directory = var.output_directory
vboxmanage = [
["modifyvm", "{{ .Name }}", "--boot1", "dvd"],
["modifyvm", "{{ .Name }}", "--boot2", "disk"],
["modifyvm", "{{ .Name }}", "--usb", "off"],
["modifyvm", "{{ .Name }}", "--vram", "128"],
["modifyvm", "{{ .Name }}", "--graphicscontroller", "vmsvga"],
["modifyvm", "{{ .Name }}", "--accelerate3d", "on"],
["modifyvm", "{{ .Name }}", "--vrde", "off"],
["modifyvm", "{{ .Name }}", "--nic1", "nat"],
["modifyvm", "{{ .Name }}", "--nic2", "hostonly"],
["modifyvm", "{{ .Name }}", "--hostonlyadapter2", "vboxnet0"],
["modifyvm", "{{ .Name }}", "--memory", "${var.memsize}"],
["modifyvm", "{{ .Name }}", "--cpus", "${var.cpus}"]
]
boot_command = [
"e<wait>",
"<down><down><down>",
"<end><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><wait>",
"nomodeset autoinstall ds=nocloud-net\\;s=http://192.168.56.1:{{ .HTTPPort }}/ net.ifnames=0<wait>",
"<f10><wait>"
]
boot_wait = "5s"
}
build {
sources = ["sources.virtualbox-iso.ubuntu-25-04"]
provisioner "ansible" {
playbook_file = "scripts/ansible/ubuntu-25-04.yml"
user = var.username
use_proxy = false
extra_arguments = [
"--extra-vars", "ansible_password='${var.password}' ansible_become_pass='${var.password}'",
]
}
post-processor "shell-local" {
inline = ["rm -f ${var.checksum_directory}/${var.img_name}-${var.arch}.*"]
}
post-processor "checksum" {
checksum_types = ["sha256", "sha512"]
output = "${var.checksum_directory}/${var.img_name}-${var.arch}.{{.ChecksumType}}"
}
}