forked from JamesWoolfenden/packer-by-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
44 lines (37 loc) · 1.13 KB
/
build.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
41
42
43
44
<#
.SYNOPSIS
A wrapper script for Packer
.DESCRIPTION
Wraps up Packer with support for environment files and Packer Debug flags
.PARAMETER Path
The path to the .
.EXAMPLE
C:\PS>build.ps1 -packfile .\packfiles\redhat\base.json -environment .\environmment\jameswoolfenden-sandbox.json
.NOTES
Author: James Woolfenden
Date: January 10, 2019
#>
param(
[Parameter(Mandatory=$true)]
[string]$packfile,
[Parameter(Mandatory=$true)]
[string]$environment)
function Invoke-Packer
{
<#
.Description
Get-Function displays the name and syntax of all functions in the session.
.Example
Invoke-Packer -packfile .\packfiles\redhat\base.json -environment .\environmment\jameswoolfenden-sandbox.json
#>
param(
[Parameter(Mandatory=$true)]
[string]$packfile,
[Parameter(Mandatory=$true)]
[string]$environment)
Write-Output "Checking $environment Found: $(test-path $environment)"
Write-Output "Checking $packfile Found: $(test-path $packfile)"
packer validate -var-file="$environment" $packfile
packer build -var-file="$environment" $packfile
}
Invoke-Packer -packfile $packfile -environment $environment