Retries starting the salt-minion service several times and adds elevated: true to salt calls

This commit is contained in:
Marno van der Molen 2014-05-19 13:14:25 +02:00
parent 01f2c52251
commit fbd919d52c
2 changed files with 30 additions and 9 deletions

View File

@ -21,7 +21,25 @@ $webclient.DownloadFile($url, $file)
Write-Host "Installing Salt minion..."
C:\tmp\salt.exe /S
# Wait a bit
Start-Sleep -s 10
net start salt-minion
# Try starting the Salt minion service
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
$try = 0
# Retry starting the service 4 times if it's not running
# and wait 2 seconds between each try
While (($service.Status -eq "Stopped") -and ($try -ne 4)) {
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
Start-Sleep -s 2
$try += 1
}
# If the salt-minion service is still not running, something probably
# went wrong and user intervention is required - report failure.
if ($service.Status -eq "Stopped") {
Write-Host "Failed to start Salt minion"
exit 1
}
Write-Host "Salt minion successfully installed"

View File

@ -282,8 +282,9 @@ module VagrantPlugins
if @config.install_master
@machine.env.ui.info "Calling state.overstate... (this may take a while)"
if @machine.config.vm.communicator == :winrm
@machine.communicate.execute("C:\\salt\\salt.exe '*' saltutil.sync_all")
@machine.communicate.execute("C:\\salt\\salt-run.exe state.over") do |type, data|
opts = { elevated: true }
@machine.communicate.execute("C:\\salt\\salt.exe '*' saltutil.sync_all", opts)
@machine.communicate.execute("C:\\salt\\salt-run.exe state.over", opts) do |type, data|
if @config.verbose
@machine.env.ui.info(data)
end
@ -309,8 +310,9 @@ module VagrantPlugins
@machine.env.ui.info "Calling state.highstate... (this may take a while)"
if @config.install_master
if @machine.config.vm.communicator == :winrm
@machine.communicate.execute("C:\\salt\\salt.exe '*' saltutil.sync_all")
@machine.communicate.execute("C:\\salt\\salt.exe '*' state.highstate --verbose#{get_loglevel}#{get_colorize}#{get_pillar}") do |type, data|
opts = { elevated: true }
@machine.communicate.execute("C:\\salt\\salt.exe '*' saltutil.sync_all", opts)
@machine.communicate.execute("C:\\salt\\salt.exe '*' state.highstate --verbose#{get_loglevel}#{get_colorize}#{get_pillar}", opts) do |type, data|
if @config.verbose
@machine.env.ui.info(data)
end
@ -325,8 +327,9 @@ module VagrantPlugins
end
else
if @machine.config.vm.communicator == :winrm
@machine.communicate.execute("C:\\salt\\salt-call.exe saltutil.sync_all")
@machine.communicate.execute("C:\\salt\\salt-call.exe state.highstate #{get_loglevel}#{get_colorize}#{get_pillar}") do |type, data|
opts = { elevated: true }
@machine.communicate.execute("C:\\salt\\salt-call.exe saltutil.sync_all", opts)
@machine.communicate.execute("C:\\salt\\salt-call.exe state.highstate #{get_loglevel}#{get_colorize}#{get_pillar}", opts) do |type, data|
if @config.verbose
@machine.env.ui.info(data)
end