forked from marcinbojko/hv-packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hv_win2019_dc_vagrant.ps1
37 lines (34 loc) · 1.02 KB
/
hv_win2019_dc_vagrant.ps1
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
# Build images
$template_file="./templates/hv_win2019_g2_vagrant.pkr.hcl"
$var_file="./variables/variables_win2019_dc.pkvars.hcl"
$machine="Windows Server 2019 Datacenter Gen-2 Vagrant"
$packer_log=0
if ((Test-Path -Path "$template_file") -and (Test-Path -Path "$var_file")) {
Write-Output "Template and var file found"
Write-Output "Building: $machine"
try {
$env:PACKER_LOG=$packer_log
packer validate -var-file="$var_file" "$template_file"
}
catch {
Write-Output "Packer validation failed, exiting."
exit (-1)
}
try {
$env:PACKER_LOG=$packer_log
packer version
packer build --force -var-file="$var_file" "$template_file"
if ($?) {
Write-Output "Calculating checksums"
Get-FileHash -Algorithm SHA256 -Path "./vbox/packer-windows-2019-dc-g2.box"|Out-File "./vbox/packer-windows-2019-dc-g2.box.sha256" -Verbose
}
}
catch {
Write-Output "Packer build failed, exiting."
exit (-1)
}
}
else {
Write-Output "Template or Var file not found - exiting"
exit (-1)
}