forked from marcinbojko/hv-packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hv_rockylinux84_docker.ps1
40 lines (36 loc) · 1.07 KB
/
hv_rockylinux84_docker.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
40
# Build images
# Get Start Time
$startDTM = (Get-Date)
# Variables
$template_file="./templates/hv_rockylinux8_g2_docker.pkr.hcl"
$var_file="./variables/variables_rockylinux84.pkvars.hcl"
$override="./variables/rockylinux8_docker.yml"
$machine="RockyLinux 8.4"
$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" -var "ansible_override=$override" "$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" -var "ansible_override=$override" "$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