Add -PackerOnly option
Add same functionality as build.sh to PS script
This commit is contained in:
12
build.ps1
12
build.ps1
@@ -25,6 +25,9 @@
|
||||
.PARAMETER PackerPath
|
||||
The full path to the packer executable. Default is C:\Hashicorp\packer.exe
|
||||
|
||||
.PARAMETER PackerOnly
|
||||
This switch skips deploying boxes with vagrant after being built by packer
|
||||
|
||||
.PARAMETER VagrantOnly
|
||||
This switch skips building packer boxes and instead downloads from Vagrant Cloud
|
||||
|
||||
@@ -48,6 +51,7 @@ Param(
|
||||
[ValidateSet('virtualbox', 'vmware_desktop')]
|
||||
[string]$ProviderName,
|
||||
[string]$PackerPath = 'C:\Hashicorp\packer.exe',
|
||||
[switch]$PackerOnly,
|
||||
[switch]$VagrantOnly
|
||||
)
|
||||
|
||||
@@ -186,6 +190,7 @@ function preflight_checks {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!($PackerOnly)) {
|
||||
Write-Host '[preflight_checks] Checking if Vagrant is installed'
|
||||
check_vagrant
|
||||
|
||||
@@ -233,6 +238,7 @@ function preflight_checks {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host '[preflight_checks] Finished.'
|
||||
}
|
||||
|
||||
@@ -262,11 +268,11 @@ function move_boxes {
|
||||
Write-Host "[move_boxes] Running.."
|
||||
Move-Item -Path $DL_DIR\Packer\*.box -Destination $DL_DIR\Boxes
|
||||
if (-Not (Test-Path "$DL_DIR\Boxes\windows_10_$PackerProvider.box")) {
|
||||
Write-Error "Windows 10 box is missing from the Boxes directory. Qutting."
|
||||
Write-Error "Windows 10 box is missing from the Boxes directory. Quitting."
|
||||
break
|
||||
}
|
||||
if (-Not (Test-Path "$DL_DIR\Boxes\windows_2016_$PackerProvider.box")) {
|
||||
Write-Error "Windows 2016 box is missing from the Boxes directory. Qutting."
|
||||
Write-Error "Windows 2016 box is missing from the Boxes directory. Quitting."
|
||||
break
|
||||
}
|
||||
Write-Host "[move_boxes] Finished."
|
||||
@@ -387,6 +393,7 @@ if (!($VagrantOnly)) {
|
||||
move_boxes
|
||||
}
|
||||
|
||||
if (!($PackerOnly)) {
|
||||
# Vagrant up each box and attempt to reload one time if it fails
|
||||
forEach ($VAGRANT_HOST in $LAB_HOSTS) {
|
||||
Write-Host "[main] Running vagrant_up_host for: $VAGRANT_HOST"
|
||||
@@ -411,3 +418,4 @@ forEach ($VAGRANT_HOST in $LAB_HOSTS) {
|
||||
Write-Host "[main] Running post_build_checks"
|
||||
post_build_checks
|
||||
Write-Host "[main] Finished post_build_checks"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user