-
Notifications
You must be signed in to change notification settings - Fork 0
/
win.export.pkr.hcl
61 lines (51 loc) · 1.52 KB
/
win.export.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
/*
win.increment.pkr.hcl: Used to run scripts on Windows. Requires a variable to be set
Example usage: `packer build -var-file="./win10/<increment>.pkrvars.hcl" -only=virtualbox* ./win.increment.pkr.hcl`
- Please note that quotations around the -var-file value seem to be required on Windows
Required vars:
- scripts - list of paths to scripts to run
*/
source "virtualbox-ovf" "windows" {
vm_name = var.vm_name
boot_wait = "30s"
headless = false
guest_additions_mode = "disable"
source_path = var.prev_path
checksum = var.prev_checksum
winrm_username = var.winrm_username
winrm_password = var.winrm_password
communicator = "winrm"
winrm_timeout = "60m"
shutdown_command = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
output_directory = local.output_directory
http_directory = "./shared-files"
}
build {
sources = [
"source.virtualbox-ovf.windows"
]
provisioner "powershell" {
scripts = var.scripts
environment_vars = [
"MACHINE_USER_PASSWORD=${var.winrm_password}",
"MACHINE_USERNAME=${var.winrm_username}",
"MACHINE_NAME=${var.vm_name}"
]
}
post-processor "checksum" {
checksum_types = ["sha256"]
output = "${local.output_directory}/${var.vm_name}.checksum"
}
}
variables {
winrm_password = "vagrant"
winrm_username = "vagrant"
script_dir = "./shared-files/windows/scripts/"
vm_name = "export"
prev_path = ""
prev_checksum = ""
scripts = ["./shared-files/windows/scripts/noop.ps1"]
}
locals {
output_directory = "./builds/${var.vm_name}"
}