Installing Puppet via Powershell Provisioner

13 views
Skip to first unread message

martink...@gmail.com

unread,
Nov 13, 2018, 7:20:47 AM11/13/18
to Packer
Hi,

I have a Windows Server 2016 packer build which completes the build of the OS to VirtualBox, but i am having an issue installing Puppet via a Powershell Provisioner. I upload the powershell file to a local directory and then run the script, but it just hangs giving no output in the cmd line. 

The script i am using is:
[Cmdletbinding()]
Param (
   # Command to execute against the wrapper
   [Parameter(Mandatory = $True)]
   [String]$Bucket
)
$ErrorActionPrefrence = "Stop";
       
$Key = "puppet-agent-5.5.0-x64.msi"
$Path = "C:\Installers";
$ErrorActionPrefrence = "Stop";

New-Item -Type Directory $Path -ErrorAction SilentlyContinue

try {
   # download Puppet agent from bucket
   Write-Host "Downloading Puppet Agent" -ForegroundColor Green;
   "Copy-Item resources/puppet-agent-5.5.0-x64.msi -Destination C:\Installers\puppet-agent-5.5.0-x64.msi"
   # gsutil cp gs://$Bucket/$Key $Path\$Key
   Write-Host "Downloaded $Object" -ForegroundColor Green;
}
catch {
   $_.Exception.Message ;
}
   
try {
   # install Puppet agent
   Write-Host "Installing Puppet Agent" -ForegroundColor Green;
   Invoke-Expression "cmd.exe /C start /wait msiexec /i '$Path\$Key' /qn PUPPET_AGENT_STARTUP_MODE=Disabled /L* 'C:\Windows\Temp\PuppetInstall.log'";
}
catch {
   throw $_.Exception.Message;
}
Remove-Item -Recurse -Force C:\ProgramData\PuppetLabs\code

I have also tried to remove the "Downloading Puppet Agent" part and used a provisioner to upload the file and then run the rest of the script, but the script will not run (the file uploads successfully).

Any ideas would be welcome and please let me know if any more detail is needed.

Thanks
Reply all
Reply to author
Forward
0 new messages