-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu-amd64.pkr.hcl
136 lines (113 loc) · 3.25 KB
/
ubuntu-amd64.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
packer {
required_plugins {
virtualbox = {
version = ">= 1.0.5"
source = "github.com/hashicorp/virtualbox"
}
vagrant = {
version = ">= 1.0.2"
source = "github.com/hashicorp/vagrant"
}
}
}
locals {
vm_name = "${var.os_version}-${var.arch}"
}
variable "iso_url" {
type = string
}
variable "iso_checksum" {
type = string
}
variable "os_version" {
type = string
}
variable "arch" {
type = string
}
variable "memory" {
type = number
}
variable "disk_size" {
type = number
}
source "virtualbox-iso" "ubuntu" {
# ISO settings
iso_url = var.iso_url
iso_checksum = var.iso_checksum
iso_interface = "sata"
# VM settings
vm_name = local.vm_name
guest_os_type = "Ubuntu_64"
disk_size = var.disk_size
memory = var.memory
hard_drive_interface = "sata"
# headless = true
# SSH settings
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "1h"
# Boot settings
boot_wait = "5s"
boot_command = [
"e<wait2>", # Enter edit mode
"<down><down><down><wait2>", # Navigate to the kernel command line
"<end><wait>", # Go to the end of the kernel line
" autoinstall ds=nocloud-net\\;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/amd64/<wait>",
"<f10>" # Boot with the changes
]
http_directory = "http"
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
vboxmanage = [
# Basic hardware
["modifyvm", "{{.Name}}", "--vram", "16"],
["modifyvm", "{{.Name}}", "--graphicscontroller", "vmsvga"],
# Firmware and CPU
["modifyvm", "{{.Name}}", "--firmware", "efi"],
["modifyvm", "{{.Name}}", "--cpu-profile", "host"],
["modifyvm", "{{.Name}}", "--pae", "on"],
["modifyvm", "{{.Name}}", "--hwvirtex", "on"],
["modifyvm", "{{.Name}}", "--vtxvpid", "on"],
["modifyvm", "{{.Name}}", "--vtxux", "on"],
# Input devices
["modifyvm", "{{.Name}}", "--mouse", "ps2"],
["modifyvm", "{{.Name}}", "--keyboard", "ps2"],
# Boot order
["modifyvm", "{{.Name}}", "--boot1", "disk"],
["modifyvm", "{{.Name}}", "--boot2", "dvd"],
["modifyvm", "{{.Name}}", "--boot3", "none"],
["modifyvm", "{{.Name}}", "--boot4", "none"],
# Network
["modifyvm", "{{.Name}}", "--macaddress1", "080027F0F51D"],
["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
# Audio
["modifyvm", "{{.Name}}", "--audio", "none"],
# Other settings
["modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
["modifyvm", "{{.Name}}", "--usb-ohci", "on"],
["modifyvm", "{{.Name}}", "--usb-ehci", "off"],
["modifyvm", "{{.Name}}", "--clipboard-mode", "disabled"]
]
}
build {
sources = ["source.virtualbox-iso.ubuntu"]
provisioner "shell" {
scripts = [
"scripts/amd64/update.sh",
"scripts/amd64/vagrant.sh",
"scripts/amd64/guest-additions.sh"
]
}
post-processors {
post-processor "vagrant" {
output = "output-vagrant/${var.os_version}.box"
}
# post-processor "vagrant-registry" {
# client_id = var.hcp_client_id
# client_secret = var.hcp_client_secret
# box_tag = "im2nguyen/ubuntu-24-04"
# version = "0.1.0"
# architecture = var.arch
# }
}
}