diff --git a/files/install_puppet.ps1 b/files/install_puppet.ps1 index 62cd2ef8..651fbfee 100644 --- a/files/install_puppet.ps1 +++ b/files/install_puppet.ps1 @@ -347,6 +347,9 @@ try { Reset-PuppetresDLL $temp_puppetres } "$_" | Out-File -FilePath (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log') + # Put relevant errors in puppet_agent_upgrade_failure.log + Get-Content -Path $Logfile | Select-String -Pattern "^Error.*$|-- Error" | Select-String -Pattern "^.*PUPPET_AGENT_ACCOUNT_PASSWORD.*$" -NotMatch | Add-Content -Path (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log') + Get-Content -Path $Logfile -Tail 10 | Select-String -Pattern "^.*PUPPET_AGENT_ACCOUNT_PASSWORD.*$" -NotMatch | Add-Content -Path (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log') } finally { Reset-PuppetServices $services_before Unlock-Installation $install_pid_lock diff --git a/lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb b/lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb index bf29fc0f..19c72d73 100644 --- a/lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb +++ b/lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb @@ -19,7 +19,7 @@ def read_content_and_delete_file(filename) # In this scenario we need to open the file in binmode and read each line # individually, then encode the result back to UTF-8 so we can sub out both # the UTF-16 header \uFEFF and the \r\n line carriages. - File.open(logfile, 'rb:UTF-16LE') { |file| file.readlines }[0].encode!('UTF-8').delete("\uFEFF").delete("\r") + File.open(logfile, 'rb:UTF-16LE') { |file| file.read.encode!('UTF-8').delete("\uFEFF").delete("\r") } else File.read(logfile) end