-
Notifications
You must be signed in to change notification settings - Fork 4
/
windows.pkr.hcl
169 lines (140 loc) · 3.72 KB
/
windows.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
164
165
166
167
168
169
packer {
required_plugins {
parallels = {
source = "github.com/hashicorp/parallels"
version = ">= 1.0.1"
}
}
}
variable "build_dir" {
type = string
default = env("PACKER_BUILD_DIR")
}
variable "template" {
type = string
}
variable "version" {
type = string
}
variable "guest_os_type" {
type = object({
parallels = string
virtualbox = string
})
}
variable "iso_url" {
type = string
}
variable "iso_checksum" {
type = string
}
variable "shutdown_args" {
type = string
default = ""
}
locals {
cpus = 2
memory_mb = 4096
communicator = {
communicator = "winrm"
winrm_timeout = "10h"
winrm_username = "vagrant"
winrm_password = "vagrant"
}
cd_files = [
"../../templates/${var.template}/Autounattend.xml",
"../../templates/${var.template}/Autounattend.generalize.xml",
"../../scripts/core/pspolicy.cmd",
"../../scripts/core/boxstarter.install.ps1",
"../../scripts/core/boxstarter.execute.ps1",
"../../scripts/core/boxstarter.package.ps1",
"../../scripts/core/startup-profile.ps1",
"../../scripts/core/shutdown.ps1",
]
shutdown = {
command = "cmd.exe /c C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -File E:\\shutdown.ps1 ${var.shutdown_args}"
timeout = "1h"
}
}
source "parallels-iso" "windows_server" {
vm_name = var.template
guest_os_type = var.guest_os_type.parallels
parallels_tools_mode = "disable"
prlctl = [
[
"set", "{{ .Name }}",
"--memsize", local.memory_mb,
"--cpus", local.cpus,
],
]
prlctl_post = []
iso_url = var.iso_url
iso_checksum = "md5:${var.iso_checksum}"
boot_wait = "0s"
communicator = local.communicator.communicator
winrm_timeout = local.communicator.winrm_timeout
winrm_username = local.communicator.winrm_username
winrm_password = local.communicator.winrm_password
cd_files = local.cd_files
shutdown_command = local.shutdown.command
shutdown_timeout = local.shutdown.timeout
}
source "virtualbox-iso" "windows_server" {
vm_name = var.template
format = "ova"
guest_os_type = var.guest_os_type.virtualbox
headless = true
firmware = "efi"
guest_additions_mode = "disable"
vboxmanage = [
[
"modifyvm", "{{ .Name }}",
"--memory", local.memory_mb,
"--cpus", local.cpus,
],
[
"modifyvm", "{{ .Name }}",
"--recordingscreens", "0",
"--recordingvideores", "1024x768",
"--recordingvideorate", "512",
"--recordingvideofps", "25",
"--recordingfile", "${var.build_dir}/capture.webm",
"--recordingopts", "vc_enabled=true,ac_enabled=true,ac_profile=med",
"--recording", "on",
],
]
vboxmanage_post = [
[
"modifyvm", "{{ .Name }}",
"--recording", "off",
],
]
hard_drive_interface = "sata"
iso_interface = "sata"
iso_url = var.iso_url
iso_checksum = "md5:${var.iso_checksum}"
boot_command = [
"<esc>",
"FS0:\\EFI\\BOOT\\BOOTX64.EFI<enter>",
"<wait1s>",
"<enter>",
]
boot_wait = "10s"
communicator = local.communicator.communicator
winrm_timeout = local.communicator.winrm_timeout
winrm_username = local.communicator.winrm_username
winrm_password = local.communicator.winrm_password
cd_files = local.cd_files
shutdown_command = local.shutdown.command
shutdown_timeout = local.shutdown.timeout
}
build {
sources = [
"source.parallels-iso.windows_server",
"source.virtualbox-iso.windows_server",
]
post-processor "vagrant" {
output = "windows_${var.template}_${var.version}.box"
vagrantfile_template = "../../templates/${var.template}/vagrantfile.template"
}
}