Merge pull request #8992 from BenjaminSchiborr/fix/master/fix_salt_windows_bootstrap

provisioners/salt: Fixes timeout issue in salt bootstrapping for windows
This commit is contained in:
Brian Cain 2017-12-07 11:27:55 -08:00 committed by GitHub
commit a724a19a5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -65,7 +65,28 @@ Write-Host "Downloading Salt minion installer $minionFilename"
$webclient = New-Object System.Net.WebClient
$url = "https://repo.saltstack.com/windows/$minionFilename"
$file = "C:\tmp\salt.exe"
$webclient.DownloadFile($url, $file)
[int]$retries = 0
Do {
try {
$retries++
$ErrorActionPreference='Stop'
$webclient.DownloadFile($url, $file)
break
} catch [Exception] {
if($retries -eq 5) {
$_
$_.GetType()
$_.Exception
$_.Exception.StackTrace
Write-Host
exit 1
}
Write-Warning "Retrying download in 2 seconds. Retry # $retries"
Start-Sleep -s 2
}
}
Until($retries -eq 5)
# Install minion silently

View File

@ -303,7 +303,7 @@ module VagrantPlugins
@machine.communicate.upload(bootstrap_path.to_s, bootstrap_destination)
@machine.communicate.sudo("chmod +x %s" % bootstrap_destination)
if @machine.config.vm.communicator == :winrm
bootstrap = @machine.communicate.sudo("powershell.exe -executionpolicy bypass -file %s %s" % [bootstrap_destination, options]) do |type, data|
bootstrap = @machine.communicate.sudo("powershell.exe -NonInteractive -NoProfile -executionpolicy bypass -file %s %s" % [bootstrap_destination, options]) do |type, data|
if data[0] == "\n"
# Remove any leading newline but not whitespace. If we wanted to
# remove newlines and whitespace we would have used data.lstrip