Merge pull request #274 from dlee35/master

Add -PackerOnly option
This commit is contained in:
Chris Long
2019-05-10 22:50:40 -07:00
committed by GitHub

View File

@@ -25,6 +25,9 @@
.PARAMETER PackerPath .PARAMETER PackerPath
The full path to the packer executable. Default is C:\Hashicorp\packer.exe 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 .PARAMETER VagrantOnly
This switch skips building packer boxes and instead downloads from Vagrant Cloud This switch skips building packer boxes and instead downloads from Vagrant Cloud
@@ -48,6 +51,7 @@ Param(
[ValidateSet('virtualbox', 'vmware_desktop')] [ValidateSet('virtualbox', 'vmware_desktop')]
[string]$ProviderName, [string]$ProviderName,
[string]$PackerPath = 'C:\Hashicorp\packer.exe', [string]$PackerPath = 'C:\Hashicorp\packer.exe',
[switch]$PackerOnly,
[switch]$VagrantOnly [switch]$VagrantOnly
) )
@@ -186,6 +190,7 @@ function preflight_checks {
break break
} }
} }
if (!($PackerOnly)) {
Write-Host '[preflight_checks] Checking if Vagrant is installed' Write-Host '[preflight_checks] Checking if Vagrant is installed'
check_vagrant check_vagrant
@@ -233,6 +238,7 @@ function preflight_checks {
break break
} }
} }
}
Write-Host '[preflight_checks] Finished.' Write-Host '[preflight_checks] Finished.'
} }
@@ -262,11 +268,11 @@ function move_boxes {
Write-Host "[move_boxes] Running.." Write-Host "[move_boxes] Running.."
Move-Item -Path $DL_DIR\Packer\*.box -Destination $DL_DIR\Boxes Move-Item -Path $DL_DIR\Packer\*.box -Destination $DL_DIR\Boxes
if (-Not (Test-Path "$DL_DIR\Boxes\windows_10_$PackerProvider.box")) { 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 break
} }
if (-Not (Test-Path "$DL_DIR\Boxes\windows_2016_$PackerProvider.box")) { 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 break
} }
Write-Host "[move_boxes] Finished." Write-Host "[move_boxes] Finished."
@@ -387,6 +393,7 @@ if (!($VagrantOnly)) {
move_boxes move_boxes
} }
if (!($PackerOnly)) {
# Vagrant up each box and attempt to reload one time if it fails # Vagrant up each box and attempt to reload one time if it fails
forEach ($VAGRANT_HOST in $LAB_HOSTS) { forEach ($VAGRANT_HOST in $LAB_HOSTS) {
Write-Host "[main] Running vagrant_up_host for: $VAGRANT_HOST" 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" Write-Host "[main] Running post_build_checks"
post_build_checks post_build_checks
Write-Host "[main] Finished post_build_checks" Write-Host "[main] Finished post_build_checks"
}