Created
December 8, 2016 13:48
-
-
Save vniklas/aa509db8797d5e94f49470f1945501e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # upgrading puppet with choco | |
| # | |
| # Niklas Akerlund | |
| # Get version of puppet agent | |
| $puppetversion = & puppet agent --version | |
| # Get the latest run of puppet | |
| $lastrun = Get-WinEvent -ProviderName Puppet -MaxEvents 35 | where {$_.Message -like "*Finished*" -or $_.Message -like "Applied*"} | sort TimeCreated -Descending | select -First 1 | select -ExpandProperty TimeCreated | |
| $datenow = Get-Date | |
| # Check version and if old version update | |
| if ($puppetversion -lt "4.8.1" -and $lastrun){ | |
| # Only update if there is no puppet apply running | |
| if ($datenow -ge $lastrun.AddMinutes(5) -and $datenow -le $lastrun.AddMinutes(25) -and !(get-process ruby -ErrorAction SilentlyContinue)){ | |
| # update Puppet client to great success version | |
| choco upgrade puppet-agent --y | |
| Write-output "fixitrix update " | |
| }else{ | |
| Write-Output "To close to apply will try again" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment