2014-05-19 12:01:31 +00:00
|
|
|
# Copy minion keys & config to correct location
|
2014-05-17 01:31:24 +00:00
|
|
|
New-Item c:\salt\conf\pki\minion\ -ItemType directory | out-null
|
2014-05-19 13:52:20 +00:00
|
|
|
|
|
|
|
# Check if minion keys have been uploaded
|
|
|
|
if (Test-Path C:\tmp\minion.pem) {
|
|
|
|
cp C:\tmp\minion.pem C:\salt\conf\pki\minion\
|
|
|
|
cp C:\tmp\minion.pub C:\salt\conf\pki\minion\
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check if minion config has been uploaded
|
|
|
|
if (Test-Path C:\tmp\minion) {
|
|
|
|
cp C:\tmp\minion C:\salt\conf\
|
|
|
|
}
|
2014-05-17 00:19:34 +00:00
|
|
|
|
|
|
|
# Detect architecture
|
|
|
|
if ([IntPtr]::Size -eq 4) {
|
|
|
|
$arch = "win32"
|
|
|
|
} else {
|
|
|
|
$arch = "AMD64"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download minion setup file
|
|
|
|
Write-Host "Downloading Salt minion installer ($arch)..."
|
|
|
|
$webclient = New-Object System.Net.WebClient
|
|
|
|
$url = "https://docs.saltstack.com/downloads/Salt-Minion-2014.1.3-1-$arch-Setup.exe"
|
|
|
|
$file = "C:\tmp\salt.exe"
|
|
|
|
$webclient.DownloadFile($url, $file)
|
|
|
|
|
|
|
|
# Install minion silently
|
|
|
|
Write-Host "Installing Salt minion..."
|
|
|
|
C:\tmp\salt.exe /S
|
|
|
|
|
2014-05-19 17:00:18 +00:00
|
|
|
# Wait for salt-minion service to be registered before trying to start it
|
2014-05-19 11:14:25 +00:00
|
|
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
2014-05-19 15:50:22 +00:00
|
|
|
While (!$service) {
|
2014-05-19 17:00:18 +00:00
|
|
|
Start-Sleep -s 2
|
|
|
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
2014-05-19 15:50:22 +00:00
|
|
|
}
|
|
|
|
|
2014-05-19 17:00:18 +00:00
|
|
|
# Start service
|
|
|
|
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
|
|
|
|
|
|
|
# Check if service is started, otherwise retry starting the
|
|
|
|
# service 4 times.
|
|
|
|
$try = 0
|
2014-05-19 15:50:22 +00:00
|
|
|
While (($service.Status -ne "Running") -and ($try -ne 4)) {
|
2014-05-19 11:14:25 +00:00
|
|
|
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"
|