forked from marcinbojko/hv-packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hv_centos79.ps1
39 lines (35 loc) · 971 Bytes
/
hv_centos79.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
37
38
39
# Build images
# Get Start Time
$startDTM = (Get-Date)
# Variables
$template_file="./templates/hv_centos7_g2.pkr.hcl"
$var_file="./variables/variables_centos79.pkvars.hcl"
$machine="CentOS 7.9 2009"
$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"
}
catch {
Write-Output "Packer build failed, exiting."
exit (-1)
}
}
else {
Write-Output "Template or Var file not found - exiting"
exit (-1)
}
$endDTM = (Get-Date)
Write-Host "[INFO] - Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds" -ForegroundColor Yellow