Hey, we want to update Puppet-Agent on Windows (:...
# bolt
k
Hey, we want to update Puppet-Agent on Windows (🤮) via bolt command:
choco upgrade puppet-agent -y --no-progress
After several minutes we get this stacktrace:
Copy code
Chocolatey v1.3.0
  Upgrading the following packages:
  puppet-agent
  By upgrading, you accept licenses for the packages.

  You have puppet-agent v7.21.0 installed. Version 7.24.0 is available based on your source(s).

  puppet-agent v7.24.0
  puppet-agent package files upgrade completed. Performing other installation steps.
  Attempt to use original download file name failed for 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\puppet-agent-7.24.0-x64.msi'.
  Copying puppet-agent
    from 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\puppet-agent-7.24.0-x64.msi'
  Installing puppet-agent...
  WARNING: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\puppet-agent_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error.
  ERROR: Running ["C:\Windows\System32\msiexec.exe" /i "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi" /passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz-qrt.com|xyz-qrt.com>" ] was not successful. Exit code was '1603'. Exit code indicates the following: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\puppet-agent_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error..
  The upgrade of puppet-agent was NOT successful.
  Error while running 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\chocolateyinstall.ps1'.
   See log for details.

  Chocolatey upgraded 0/1 packages. 1 packages failed.
   See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

  Failures
   - puppet-agent (exited 1603) - Error while running 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\chocolateyinstall.ps1'.
   See log for details.
chocolatey.log:
Copy code
2023-04-14 16:03:49,867 4280 [DEBUG] - Running Install-ChocolateyInstallPackage -packageName 'puppet-agent' -fileType 'msi' -silentArgs '/passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz.qrt.com|xyz.qrt.com>"' -file 'C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi' -validExitCodes '0 3010 1641' -useOnlyPackageSilentArguments 'False' 
2023-04-14 16:03:49,898 4280 [DEBUG] - Running Get-OSArchitectureWidth -compare '32' 
2023-04-14 16:03:49,914 4280 [INFO ] - Installing puppet-agent...
2023-04-14 16:03:49,930 4280 [INFO ] - 
2023-04-14 16:03:50,008 4280 [DEBUG] - Ensuring 'C:\Users\devuser\AppData\Local\Temp\chocolatey' exists
2023-04-14 16:03:50,039 4280 [DEBUG] - Running Start-ChocolateyProcessAsAdmin -validExitCodes '0 3010 1641' -workingDirectory 'C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0' -statements '/i "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi" /passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz.qrt.com|xyz.qrt.com>" ' -exeToRun 'C:\Windows\System32\msiexec.exe' 
2023-04-14 16:03:50,086 4280 [DEBUG] - Test-ProcessAdminRights: returning True
2023-04-14 16:03:50,117 4280 [DEBUG] - Elevating permissions and running ["C:\Windows\System32\msiexec.exe" /i "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi" /passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz-qrt.com|xyz-qrt.com>" ]. This may take a while, depending on the statements.
2023-04-14 16:08:37,941 4280 [DEBUG] - Command ["C:\Windows\System32\msiexec.exe" /i "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi" /passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz.qrt.com|xyz.qrt.com>" ] exited with '1603'.
2023-04-14 16:08:37,956 4280 [WARN ] - WARNING: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\puppet-agent_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error.
2023-04-14 16:08:38,003 4280 [ERROR] - ERROR: Running ["C:\Windows\System32\msiexec.exe" /i "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent\7.24.0\puppet-agentInstall.msi" /passive /norestart /l*v "C:\Users\devuser\AppData\Local\Temp\chocolatey\puppet-agent.7.24.0.MsiInstall.log" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME="<http://xyz.qrt.com|xyz.qrt.com>" ] was not successful. Exit code was '1603'. Exit code indicates the following: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\puppet-agent_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error..
2023-04-14 16:08:38,019 4280 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\chocolateyinstall.ps1' -installArguments '' -packageParameters '' -preRunHookScripts $null -postRunHookScripts $null'] exited with '1603'.
[...]
2023-04-14 16:08:38,862 4280 [ERROR] - The upgrade of puppet-agent was NOT successful.
2023-04-14 16:08:38,878 4280 [ERROR] - Error while running 'C:\ProgramData\chocolatey\lib\puppet-agent\tools\chocolateyinstall.ps1'.
 See log for details.
If we run the command
choco upgrade puppet-agent -y --no-progress
directly on the server in powershell it works like a charm. Content of C:\ProgramData\chocolatey\lib\puppet-agent\tools\chocolateyinstall.ps1 is
Copy code
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'puppet-agent-7.24.0-x64.msi'
$puppetconfLocation = "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
$puppetSearchCertname = "$(Get-Content $puppetconfLocation | Select-String -Pattern 'certname' -CaseSensitive)"
$puppetSplitCertname = $($puppetSearchCertname.Split('='))
$puppetCertname = $($puppetSplitCertname[1].Split('',[System.StringSplitOptions]::RemoveEmptyEntries))

$packageArgs = @{
  packageName   = $env:ChocolateyPackageName
  unzipLocation = $toolsDir
  fileType      = 'msi'
  file          = $fileLocation
  softwareName  = 'Puppet Agent*'
  silentArgs    = "/passive /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`" PUPPET_AGENT_STARTUP_MODE=Disabled PUPPET_MASTER_SERVER=<http://abc.def.com|abc.def.com> PUPPET_MASTER_PORT=8140 PUPPET_AGENT_CERTNAME=`"$($puppetCertname)`"" # MSIRESTARTMANAGERCONTROL=Disable REBOOT=ReallySuppress
  validExitCodes= @(0, 3010, 1641)
}

Install-ChocolateyPackage @packageArgs
Has someone any ideas to fix this problem? 🔨