-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into stable for release
- Loading branch information
Showing
5 changed files
with
259 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,13 @@ Angelo Gründler plueschopath [email protected] | |
Ari Aosved devaos [email protected] | ||
Boris Feld Lothiraldan | ||
Brad Thurber bradthurber | ||
Bret Fisher BretFisher [email protected] | ||
bruce-one bruce-one | ||
C. R. Oldham cro [email protected] | ||
Cam camereonsparr | ||
Chris Rebert cvrebert [email protected] | ||
Christer Edwards cedwards | ||
denmat denmat | ||
Dag Viggo Lokøen dagvl [email protected] | ||
Dan Mick dmick [email protected] | ||
David J. Felix DavidJFelix | ||
|
@@ -41,6 +43,7 @@ Jeff Strunk jstrunk | |
Juan A. Moyano wincus [email protected] | ||
Karl Grzeszczak karlgrz | ||
Kenneth Wilke KennethWilke | ||
lomeroe lomeroe | ||
Liu Xiaohui oreh [email protected] | ||
Mark Lee malept | ||
markgaylard markgaylard | ||
|
@@ -73,5 +76,6 @@ Tony Narlock tony | |
Valentin Bud valentinbud [email protected] | ||
Vladimir Kozhukalov kozhukalov | ||
Whit Morriss whitmo [email protected] | ||
Wolodja Wentland babilen [email protected] | ||
Wout wfhg | ||
========================== ===================== ============================ |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<# | ||
.SYNOPSIS | ||
A simple Powershell script to download and install a salt minion on windows. | ||
.DESCRIPTION | ||
The script will download the official salt package from saltstack. It will install a specific | ||
package version and accept parameters for the master and minion ids. Finally, it can stop and | ||
set the windows service to "manual" for local testing. | ||
.EXAMPLE | ||
./bootstrap-salt.ps1 | ||
Runs without any parameters. Uses all the default values/settings. | ||
.EXAMPLE | ||
./bootstrap-salt.ps1 -version 2015.4.1-3 | ||
Specifies a particular version of the installer. | ||
.EXAMPLE | ||
./bootstrap-salt.ps1 -runservice false | ||
Specifies the salt-minion service to stop and be set to manual. | ||
Useful for testing locally from the command line with the --local switch | ||
.EXAMPLE | ||
./bootstrap-salt.ps1 -minion minion-box -master master-box | ||
Specifies the minion and master ids in the minion config. | ||
Defaults to the installer values of "minion" and "master". | ||
.EXAMPLE | ||
./bootstrap-salt.ps1 -minion minion-box -master master-box -version 2015.5.2 -runservice false | ||
Specifies all the optional parameters in no particular order. | ||
.PARAMETER version - Default version defined in this script. | ||
.PARAMETER runservice - Boolean flag to stop the windows service and set to "manual". | ||
Installer starts it by default. | ||
.PARAMETER minion - Name of the minion being installed on this host. | ||
Installer defaults to "minion". | ||
.PARAMETER master - Name or IP of the master server the minion. Installer defaults to "master". | ||
.NOTES | ||
All of the parameters are optional. The default should be the latest version. The architecture | ||
is dynamically determined by the script. | ||
.LINK | ||
Bootstrap GitHub Project (script home) - https://github.com/saltstack/salt-windows-bootstrap | ||
Original Vagrant Provisioner Project -https://github.com/saltstack/salty-vagrant | ||
Vagrant Project (utilizes this script) - https://github.com/mitchellh/vagrant | ||
SaltStack Download Location - http://docs.saltstack.com/downloads/ | ||
#> | ||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)] | ||
# Doesn't support versions prior to "YYYY.M.R-B" | ||
[ValidatePattern('^(201[0-9]\.[0-9]\.[0-9](\-\d{1})?)$')] | ||
[string]$version = "2015.5.2", | ||
|
||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)] | ||
[ValidateSet("true","false")] | ||
[string]$runservice = "true", | ||
|
||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)] | ||
[string]$minion = "salt-minion", | ||
|
||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)] | ||
[string]$master = "master" | ||
) | ||
|
||
Write-Verbose "Parameters passed in:" | ||
Write-Verbose "version: $version" | ||
Write-Verbose "runservice: $runservice" | ||
Write-Verbose "master: $master" | ||
Write-Verbose "minion: $minion" | ||
|
||
If ($runservice.ToLower() -eq "true"){ | ||
Write-Verbose "Windows service will be set to run" | ||
[bool]$runservice = $True | ||
} | ||
ElseIf ($runservice.ToLower() -eq "false"){ | ||
Write-Verbose "Windows service will be stopped and set to manual" | ||
[bool]$runservice = $False | ||
} | ||
Else { | ||
# Param passed in wasn't clear so defaulting to true. | ||
Write-Verbose "Windows service defaulting to run automatically" | ||
[bool]$runservice = $True | ||
} | ||
|
||
# Create C:\tmp\ - if Vagrant doesn't upload keys and/or config it might not exist | ||
New-Item C:\tmp\ -ItemType directory -force | out-null | ||
|
||
# Copy minion keys & config to correct location | ||
New-Item C:\salt\conf\pki\minion\ -ItemType directory -force | out-null | ||
|
||
# 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\ | ||
} | ||
|
||
# Detect architecture | ||
If ([IntPtr]::Size -eq 4) { | ||
$arch = "x86" | ||
} Else { | ||
$arch = "AMD64" | ||
} | ||
|
||
# Download minion setup file | ||
Write-Host "Downloading Salt minion installer Salt-Minion-$version-$arch-Setup.exe" | ||
$webclient = New-Object System.Net.WebClient | ||
$url = "https://docs.saltstack.com/downloads/Salt-Minion-$version-$arch-Setup.exe" | ||
$file = "C:\tmp\salt.exe" | ||
$webclient.DownloadFile($url, $file) | ||
|
||
# Install minion silently | ||
Write-Host "Installing Salt minion" | ||
#Wait for process to exit before continuing. | ||
C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null | ||
|
||
|
||
# Check if minion config has been uploaded | ||
If (Test-Path C:\tmp\minion) { | ||
cp C:\tmp\minion C:\salt\conf\ | ||
} | ||
|
||
# Wait for salt-minion service to be registered before trying to start it | ||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue | ||
While (!$service) { | ||
Start-Sleep -s 2 | ||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue | ||
} | ||
|
||
If($runservice) { | ||
# Start service | ||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue | ||
|
||
# Check if service is started, otherwise retry starting the | ||
# service 4 times. | ||
$try = 0 | ||
While (($service.Status -ne "Running") -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 | ||
} | ||
} | ||
Else { | ||
Write-Host "Stopping salt minion and setting it to 'Manual'" | ||
Set-Service "salt-minion" -startupType "Manual" | ||
Stop-Service "salt-minion" | ||
} | ||
|
||
Write-Host "Salt minion successfully installed" |
Oops, something went wrong.