-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet-bootstrap.ps1
34 lines (28 loc) · 1.12 KB
/
puppet-bootstrap.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
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True, Position=1)]
[String]$PuppetMasterHostname,
[Parameter(Mandatory=$True, Position=2)]
[String]$PuppetMasterPort,
[Parameter(Mandatory=$false, Position=3)]
[String]$Environment
)
Start-BitsTransfer "https://downloads.puppetlabs.com/windows/puppet-agent-x64-latest.msi" -Destination "$($env:TEMP)"
$MSIArguments = @(
"/qn",
"/norestart"
"/i",
"$($env:TEMP)\puppet-agent-x64-latest.msi",
"PUPPET_MASTER_SERVER=$($PuppetMasterHostname)"
)
Write-Host "Installing Puppet with arguments: $($MSIArguments)"
$process = Start-Process -FilePath msiexec.exe -ArgumentList $MSIArguments -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Host "Installer failed with code $($process.ExitCode)"
Exit 1
}
$puppetExe = "C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat"
Start-Process -FilePath $puppetExe -ArgumentList @("config", "set", "masterport", $PuppetMasterPort) -Wait -PassThru
if ($Environment) {
Start-Process -FilePath $puppetExe -ArgumentList @("config", "set", "environment", $Environment) -Wait -PassThru
}