-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu.pkr.hcl
77 lines (65 loc) · 1.5 KB
/
ubuntu.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
# Build vars
variable "vm_name" {
type = string
default = "packer-jammy"
}
variable "ssh_username" {
type = string
default = "user"
}
variable "ssh_password" {
type = string
default = "password"
sensitive = true
}
variable "ova_source_path" {
type = string
default = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.ova"
}
# Checksum disabled while we are modifying the Jammy OVA
# variable "ova_source_checksum" {
# type = string
# default = "sha256:80decd92b39aad995bb1a7a01ae64680514f33d5ef4e117c5193f0eab376294c"
# }
variable "data_directory" {
type = string
default = "./vm_data"
}
# Virtual Machine vars
variable "headless" {
type = bool
default = true
}
variable "vm_cpu_cores" {
type = number
default = 2
}
variable "vm_mem_size" {
type = number
default = 2048
}
source "virtualbox-ovf" "jammy" {
vm_name = var.vm_name
source_path = var.ova_source_path
# checksum = var.ova_source_checksum
headless = var.headless
cd_files = ["${var.data_directory}/*"]
cd_label = "cidata"
ssh_password = var.ssh_password
ssh_username = var.ssh_username
ssh_port = 22
ssh_timeout = "30m"
shutdown_command = "sudo -S -E shutdown -P now"
shutdown_timeout = "5m"
vboxmanage = [
["modifyvm", "{{ .Name }}", "--cpus", var.vm_cpu_cores],
["modifyvm", "{{ .Name }}", "--memory", var.vm_mem_size],
]
}
build {
sources = [
"source.virtualbox-ovf.jammy"]
provisioner "shell" {
inline = ["echo 'Hello, world' > ~/hello.txt"]
}
}