-
Notifications
You must be signed in to change notification settings - Fork 93
/
hyperv-ubuntu-18.04.pkr.hcl
105 lines (90 loc) · 2.63 KB
/
hyperv-ubuntu-18.04.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
variable "cpu" {
type = string
default = "2"
}
variable "disk_size" {
type = string
default = "21440"
}
variable "hyperv_switchname" {
type = string
default = "${env("hyperv_switchname")}"
}
variable "iso_checksum" {
type = string
default = "8c5fc24894394035402f66f3824beb7234b757dd2b5531379cb310cedfdf0996"
}
variable "iso_checksum_type" {
type = string
default = "sha256"
}
variable "iso_url" {
type = string
default = "http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/ubuntu-18.04.5-server-amd64.iso"
}
variable "password" {
type = string
default = "vagrant"
}
variable "ram_size" {
type = string
default = "2048"
}
variable "username" {
type = string
default = "vagrant"
}
variable "vm_name" {
type = string
default = "ubuntu-bionic"
}
source "hyperv-iso" "ubuntu" {
boot_command = [
"<esc><wait10><esc><esc><enter><wait>",
"set gfxpayload=1024x768<enter>",
"linux /install/vmlinuz ",
"preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/18.04/preseed.cfg ",
"debian-installer=en_US.UTF-8 auto locale=en_US.UTF-8 kbd-chooser/method=us ",
"hostname={{.Name}} ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA console-setup/ask_detect=false <enter>",
"initrd /install/initrd.gz<enter>",
"boot<enter>"
]
boot_wait = "5s"
communicator = "ssh"
cpus = "${var.cpu}"
disk_size = "${var.disk_size}"
enable_secure_boot = false
generation = 2
guest_additions_mode = "disable"
http_directory = "./linux/ubuntu/http/"
iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum}"
iso_url = "${var.iso_url}"
memory = "${var.ram_size}"
shutdown_command = "echo 'vagrant' | sudo -S -E shutdown -P now"
ssh_password = "${var.password}"
ssh_timeout = "4h"
ssh_username = "${var.username}"
switch_name = "${var.hyperv_switchname}"
vm_name = "${var.vm_name}"
}
build {
sources = ["source.hyperv-iso.ubuntu"]
provisioner "shell" {
execute_command = "echo 'vagrant' | sudo -S -E sh {{ .Path }}"
scripts = [
"./linux/ubuntu/update.sh",
"./linux/ubuntu/network.sh",
"./linux/common/vagrant.sh",
"./linux/common/chef.sh",
"./linux/common/motd.sh",
"./linux/ubuntu/cleanup.sh"
]
}
post-processor "vagrant" {
keep_input_artifact = true
output = "${source.type}_ubuntu-18.04_chef.box"
}
}