mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Merge branch 'develop' into 'stable'
This commit is contained in:
commit
9c0e36b411
6 changed files with 564 additions and 433 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,7 @@
|
||||||
/.project
|
/.project
|
||||||
*.swp
|
*.swp
|
||||||
.vagrant
|
.vagrant
|
||||||
|
|
||||||
|
# Pycharm
|
||||||
|
.idea
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ abednarik abednarik alejandro.bednarik@gmail.com
|
||||||
Adam Wright hipikat adam@hipikat.org
|
Adam Wright hipikat adam@hipikat.org
|
||||||
Alec Koumjian akoumjian akoumjian@gmail.com
|
Alec Koumjian akoumjian akoumjian@gmail.com
|
||||||
Alex Van't Hof alexvh
|
Alex Van't Hof alexvh
|
||||||
|
Alexander Krasnukhin themalkolm the.malkolm@gmail.com
|
||||||
Angelo Gründler plueschopath angelo.gruendler@w1r3.net
|
Angelo Gründler plueschopath angelo.gruendler@w1r3.net
|
||||||
Ari Aosved devaos ari.aosved@gmail.com
|
Ari Aosved devaos ari.aosved@gmail.com
|
||||||
Beau Hargis beaucephus beau@customermobile.com
|
Beau Hargis beaucephus beau@customermobile.com
|
||||||
|
@ -27,6 +28,7 @@ Christer Edwards cedwards
|
||||||
Clark Perkins iclarkperkins clark.perkins@digitalreasoning.com
|
Clark Perkins iclarkperkins clark.perkins@digitalreasoning.com
|
||||||
Dag Viggo Lokøen dagvl dag.viggo@lokoen.org
|
Dag Viggo Lokøen dagvl dag.viggo@lokoen.org
|
||||||
Dan Mick dmick dan.mick@inktank.com
|
Dan Mick dmick dan.mick@inktank.com
|
||||||
|
Daniel Poelzleithner poelzi
|
||||||
David J. Felix DavidJFelix
|
David J. Felix DavidJFelix
|
||||||
denmat denmat
|
denmat denmat
|
||||||
Denys Havrysh vutny denys.gavrysh@gmail.com
|
Denys Havrysh vutny denys.gavrysh@gmail.com
|
||||||
|
@ -57,6 +59,7 @@ Karl Grzeszczak karlgrz
|
||||||
Kenneth Wilke KennethWilke
|
Kenneth Wilke KennethWilke
|
||||||
lomeroe lomeroe
|
lomeroe lomeroe
|
||||||
Liu Xiaohui oreh herolxh@gmail.com
|
Liu Xiaohui oreh herolxh@gmail.com
|
||||||
|
Marc Vieira-Cardinal marccadinal
|
||||||
Mark Lee malept
|
Mark Lee malept
|
||||||
Marcus Furlong furlongm furlongm@gmail.com
|
Marcus Furlong furlongm furlongm@gmail.com
|
||||||
markgaylard markgaylard
|
markgaylard markgaylard
|
||||||
|
@ -70,6 +73,7 @@ Michael Scherer mscherer
|
||||||
Michele Bologna mbologna michele.bologna@gmail.com
|
Michele Bologna mbologna michele.bologna@gmail.com
|
||||||
Mike Carlson m87carlson mike@bayphoto.com
|
Mike Carlson m87carlson mike@bayphoto.com
|
||||||
Mike Place cachedout mp@saltstack.com
|
Mike Place cachedout mp@saltstack.com
|
||||||
|
nasenbaer13 nasenbaer13
|
||||||
nevins-b nevins-b
|
nevins-b nevins-b
|
||||||
Nicole Thomas rallytime nicole@saltstack.com
|
Nicole Thomas rallytime nicole@saltstack.com
|
||||||
Niels Abspoel aboe76 aboe76@gmail.com
|
Niels Abspoel aboe76 aboe76@gmail.com
|
||||||
|
@ -93,6 +97,7 @@ Ronald van Zantvoort The-Loeki ronald@pcextreme.nl
|
||||||
RuriRyan RuriRyan ryan@btsoft.eu
|
RuriRyan RuriRyan ryan@btsoft.eu
|
||||||
Ryan Walder ryanwalder ryanwalder@ucds.email
|
Ryan Walder ryanwalder ryanwalder@ucds.email
|
||||||
Sergey Paramonov serge-p serg.paramonov@s-vp.com
|
Sergey Paramonov serge-p serg.paramonov@s-vp.com
|
||||||
|
Shane Lee twangboy slee@saltstack.com
|
||||||
Shawn Butts shawnbutts
|
Shawn Butts shawnbutts
|
||||||
Skyler Berg skylerberg skylertheberg@gmail.com
|
Skyler Berg skylerberg skylertheberg@gmail.com
|
||||||
Stanislav B stanislavb
|
Stanislav B stanislavb
|
||||||
|
|
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
Version 2016.06.24:
|
||||||
|
* Save invocation command and arguments into variables. (jfindlay) #885
|
||||||
|
* Update the authors list with new contributors. (rallytime) #884
|
||||||
|
* Add option to make setup.py install quiet. (nasenbaer13) #865
|
||||||
|
* Fix lint. (jfindlay) #881
|
||||||
|
* Add -R option to allow a custom repo URL. (rallytime) #877
|
||||||
|
* Exclude path of script when called from another dir. (l2ol33rt) #871
|
||||||
|
* Print invocation info. (jfindlay) #869
|
||||||
|
* Always refresh the Arch Linux keyring if needed. (cachedout) #868
|
||||||
|
* Ubuntu 16.04 LTS Xenial Support. (notpeter) #852
|
||||||
|
* Install Salt packages from repo.saltstack.com on Debian 7 "Wheezy". (vutny) #864
|
||||||
|
* Drop support for Debian 6 old-old-stable "squeeze": reached end-of-life. (vutny) #860
|
||||||
|
* Removed ubuntu version restriction for apt-get update. (marccardinal) #859
|
||||||
|
* Fix bootstrapping from git on Debian 8 by installing latest `tornado` via pip. (vutny) #828
|
||||||
|
* Add the ability to override master and/or minion configs from CLI. (rallytime) #841
|
||||||
|
* Don't sleep 11 seconds if the user allowed overwrite of config files. (poelzi) #832
|
||||||
|
|
||||||
Version 2016.05.11:
|
Version 2016.05.11:
|
||||||
* Only overwrite the minion config file if '-C' is passed. Otherwise, preserve it. (rallytime) #848
|
* Only overwrite the minion config file if '-C' is passed. Otherwise, preserve it. (rallytime) #848
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ Supported Operating Systems
|
||||||
Debian and derivatives
|
Debian and derivatives
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
- Debian GNU/Linux 6/7/8
|
- Debian GNU/Linux 7/8
|
||||||
- Linux Mint Debian Edition 1 (based on Debian 8)
|
- Linux Mint Debian Edition 1 (based on Debian 8)
|
||||||
- Kali Linux 1.0 (based on Debian 7)
|
- Kali Linux 1.0 (based on Debian 7)
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ Ubuntu and derivatives
|
||||||
- Linaro 12.04
|
- Linaro 12.04
|
||||||
- Linux Mint 13/14/16/17
|
- Linux Mint 13/14/16/17
|
||||||
- Trisquel GNU/Linux 6 (based on Ubuntu 12.04)
|
- Trisquel GNU/Linux 6 (based on Ubuntu 12.04)
|
||||||
- Ubuntu 10.x/11.x/12.x/13.x/14.x/15.04
|
- Ubuntu 10.x/11.x/12.x/13.x/14.x/15.x/16.04
|
||||||
|
|
||||||
|
|
||||||
Other Linux distro
|
Other Linux distro
|
||||||
|
|
|
@ -1,147 +1,250 @@
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
A simple Powershell script to download and install a salt minion on windows.
|
A simple Powershell script to download and install a salt minion on windows.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
The script will download the official salt package from saltstack. It will install a specific
|
The script will download the official salt package from saltstack. It will
|
||||||
package version and accept parameters for the master and minion ids. Finally, it can stop and
|
install a specific package version and accept parameters for the master and
|
||||||
set the windows service to "manual" for local testing.
|
minion ids. Finally, it can stop and set the windows service to "manual" for
|
||||||
|
local testing.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
./bootstrap-salt.ps1
|
./bootstrap-salt.ps1
|
||||||
Runs without any parameters. Uses all the default values/settings.
|
Runs without any parameters. Uses all the default values/settings.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
./bootstrap-salt.ps1 -version 2015.4.1-3
|
./bootstrap-salt.ps1 -version 2015.4.1-3
|
||||||
Specifies a particular version of the installer.
|
Specifies a particular version of the installer.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
./bootstrap-salt.ps1 -runservice false
|
./bootstrap-salt.ps1 -runservice false
|
||||||
Specifies the salt-minion service to stop and be set to manual.
|
Specifies the salt-minion service to stop and be set to manual. Useful for
|
||||||
Useful for testing locally from the command line with the --local switch
|
testing locally from the command line with the --local switch
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
./bootstrap-salt.ps1 -minion minion-box -master master-box
|
./bootstrap-salt.ps1 -minion minion-box -master master-box
|
||||||
Specifies the minion and master ids in the minion config.
|
Specifies the minion and master ids in the minion config. Defaults to the
|
||||||
Defaults to the installer values of "minion" and "master".
|
installer values of host name for the minion id and "salt" for the master.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
./bootstrap-salt.ps1 -minion minion-box -master master-box -version 2015.5.2 -runservice false
|
./bootstrap-salt.ps1 -minion minion-box -master master-box -version 2015.5.2 -runservice false
|
||||||
Specifies all the optional parameters in no particular order.
|
Specifies all the optional parameters in no particular order.
|
||||||
|
|
||||||
.PARAMETER version - Default version defined in this script.
|
.PARAMETER version
|
||||||
|
Default version defined in this script.
|
||||||
|
|
||||||
.PARAMETER runservice - Boolean flag to stop the windows service and set to "manual".
|
.PARAMETER runservice
|
||||||
Installer starts it by default.
|
Boolean flag to start or stop the minion service. True will start the minion
|
||||||
|
service. False will stop the minion service and set it to "manual". The
|
||||||
|
installer starts it by default.
|
||||||
|
|
||||||
.PARAMETER minion - Name of the minion being installed on this host.
|
.PARAMETER minion
|
||||||
Installer defaults to "minion".
|
Name of the minion being installed on this host. Installer defaults to the
|
||||||
|
host name.
|
||||||
|
|
||||||
.PARAMETER master - Name or IP of the master server the minion. Installer defaults to "master".
|
.PARAMETER master
|
||||||
|
Name or IP of the master server. Installer defaults to "salt".
|
||||||
|
|
||||||
|
.PARAMETER repourl
|
||||||
|
URL to the windows packages. Default is "https://repo.saltstack.com/windows"
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
All of the parameters are optional. The default should be the latest version. The architecture
|
All of the parameters are optional. The default should be the latest
|
||||||
is dynamically determined by the script.
|
version. The architecture is dynamically determined by the script.
|
||||||
|
|
||||||
.LINK
|
.LINK
|
||||||
Bootstrap GitHub Project (script home) - https://github.com/saltstack/salt-windows-bootstrap
|
Bootstrap GitHub Project (script home) - https://github.com/saltstack/salt-windows-bootstrap
|
||||||
Original Vagrant Provisioner Project -https://github.com/saltstack/salty-vagrant
|
Original Vagrant Provisioner Project -https://github.com/saltstack/salty-vagrant
|
||||||
Vagrant Project (utilizes this script) - https://github.com/mitchellh/vagrant
|
Vagrant Project (utilizes this script) - https://github.com/mitchellh/vagrant
|
||||||
SaltStack Download Location - https://repo.saltstack.com/windows/
|
SaltStack Download Location - https://repo.saltstack.com/windows/
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Commandlet Binding
|
||||||
|
#===============================================================================
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||||
# Doesn't support versions prior to "YYYY.M.R-B"
|
# Doesn't support versions prior to "YYYY.M.R-B"
|
||||||
[ValidatePattern('^(201[0-9]\.[0-9]\.[0-9](\-\d{1})?)$')]
|
[ValidatePattern('^201\d\.\d{1,2}\.\d{1,2}(\-\d{1})?|(rc\d)$')]
|
||||||
[string]$version = '',
|
[string]$version = '',
|
||||||
|
|
||||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
|
||||||
[ValidateSet("true","false")]
|
|
||||||
[string]$runservice = "true",
|
|
||||||
|
|
||||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||||
[string]$minion = "salt-minion",
|
[ValidateSet("true","false")]
|
||||||
|
[string]$runservice = "true",
|
||||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
|
||||||
[string]$master = "master"
|
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||||
|
[string]$minion = "not-specified",
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||||
|
[string]$master = "not-specified",
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||||
|
[string]$repourl= "https://repo.saltstack.com/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Script Functions
|
||||||
|
#===============================================================================
|
||||||
|
function Get-IsAdministrator
|
||||||
|
{
|
||||||
|
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
$Principal = New-Object System.Security.Principal.WindowsPrincipal($Identity)
|
||||||
|
$Principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IsUacEnabled
|
||||||
|
{
|
||||||
|
(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System).EnableLua -ne 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Check for Elevated Privileges
|
||||||
|
#===============================================================================
|
||||||
|
If (!(Get-IsAdministrator)) {
|
||||||
|
If (Get-IsUacEnabled) {
|
||||||
|
# We are not running "as Administrator" - so relaunch as administrator
|
||||||
|
# Create a new process object that starts PowerShell
|
||||||
|
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
|
||||||
|
|
||||||
|
# Specify the current script path and name as a parameter`
|
||||||
|
$parameters = ""
|
||||||
|
If($minion -ne "not-specified") {$parameters = "-minion $minion"}
|
||||||
|
If($master -ne "not-specified") {$parameters = "$parameters -master $master"}
|
||||||
|
If($runservice -eq $false) {$parameters = "$parameters -runservice false"}
|
||||||
|
If($version -ne '') {$parameters = "$parameters -version $version"}
|
||||||
|
$newProcess.Arguments = $myInvocation.MyCommand.Definition, $parameters
|
||||||
|
|
||||||
|
# Specify the current working directory
|
||||||
|
$newProcess.WorkingDirectory = "$script_path"
|
||||||
|
|
||||||
|
# Indicate that the process should be elevated
|
||||||
|
$newProcess.Verb = "runas";
|
||||||
|
|
||||||
|
# Start the new process
|
||||||
|
[System.Diagnostics.Process]::Start($newProcess);
|
||||||
|
|
||||||
|
# Exit from the current, unelevated, process
|
||||||
|
Exit
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Throw "You must be administrator to run this script"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Verify Parameters
|
||||||
|
#===============================================================================
|
||||||
Write-Verbose "Parameters passed in:"
|
Write-Verbose "Parameters passed in:"
|
||||||
Write-Verbose "version: $version"
|
Write-Verbose "version: $version"
|
||||||
Write-Verbose "runservice: $runservice"
|
Write-Verbose "runservice: $runservice"
|
||||||
Write-Verbose "master: $master"
|
Write-Verbose "master: $master"
|
||||||
Write-Verbose "minion: $minion"
|
Write-Verbose "minion: $minion"
|
||||||
|
Write-Verbose "repourl: $repourl"
|
||||||
|
|
||||||
If ($runservice.ToLower() -eq "true"){
|
If ($runservice.ToLower() -eq "true") {
|
||||||
Write-Verbose "Windows service will be set to run"
|
Write-Verbose "Windows service will be set to run"
|
||||||
[bool]$runservice = $True
|
[bool]$runservice = $True
|
||||||
}
|
}
|
||||||
ElseIf ($runservice.ToLower() -eq "false"){
|
ElseIf ($runservice.ToLower() -eq "false") {
|
||||||
Write-Verbose "Windows service will be stopped and set to manual"
|
Write-Verbose "Windows service will be stopped and set to manual"
|
||||||
[bool]$runservice = $False
|
[bool]$runservice = $False
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
# Param passed in wasn't clear so defaulting to true.
|
# Param passed in wasn't clear so defaulting to true.
|
||||||
Write-Verbose "Windows service defaulting to run automatically"
|
Write-Verbose "Windows service defaulting to run automatically"
|
||||||
[bool]$runservice = $True
|
[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
|
# Ensure Directories are present, copy Vagrant Configs if found
|
||||||
|
#===============================================================================
|
||||||
|
# Create C:\tmp\
|
||||||
|
New-Item C:\tmp\ -ItemType directory -Force | Out-Null
|
||||||
|
|
||||||
# Copy minion keys & config to correct location
|
# Copy Vagrant Files to their proper location. Vagrant files will be placed
|
||||||
New-Item C:\salt\conf\pki\minion\ -ItemType directory -force | out-null
|
# in C:\tmp
|
||||||
|
# Check if minion keys have been uploaded, copy to correct location
|
||||||
# Check if minion keys have been uploaded
|
|
||||||
If (Test-Path C:\tmp\minion.pem) {
|
If (Test-Path C:\tmp\minion.pem) {
|
||||||
cp C:\tmp\minion.pem C:\salt\conf\pki\minion\
|
New-Item C:\salt\conf\pki\minion\ -ItemType Directory -Force | Out-Null
|
||||||
cp C:\tmp\minion.pub C:\salt\conf\pki\minion\
|
# Copy minion keys & config to correct location
|
||||||
|
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
|
||||||
|
# This should be done before the installer is run so that it can be updated with
|
||||||
|
# id: and master: settings when the installer runs
|
||||||
|
If (Test-Path C:\tmp\minion) {
|
||||||
|
New-Item C:\salt\conf\ -ItemType Directory -Force | Out-Null
|
||||||
|
Copy-Item -Path C:\tmp\minion -Destination C:\salt\conf\ -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
# Detect architecture
|
# Detect architecture
|
||||||
|
#===============================================================================
|
||||||
If ([IntPtr]::Size -eq 4) {
|
If ([IntPtr]::Size -eq 4) {
|
||||||
$arch = "x86"
|
$arch = "x86"
|
||||||
} Else {
|
}
|
||||||
$arch = "AMD64"
|
Else {
|
||||||
|
$arch = "AMD64"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Figure out the latest version if no version is passed
|
||||||
|
#===============================================================================
|
||||||
# If version isn't supplied, use latest.
|
# If version isn't supplied, use latest.
|
||||||
if (!$version) {
|
If (!$version) {
|
||||||
# Find latest version of Salt Minion
|
# Find latest version of Salt Minion
|
||||||
$repo = Invoke-Restmethod 'http://repo.saltstack.com/windows/'
|
$repo = Invoke-Restmethod "$repourl"
|
||||||
$regex = "<\s*a\s*[^>]*?href\s*=\s*[`"']*([^`"'>]+)[^>]*?>"
|
$regex = "<\s*a\s*[^>]*?href\s*=\s*[`"']*([^`"'>]+)[^>]*?>"
|
||||||
$returnMatches = new-object System.Collections.ArrayList
|
$returnMatches = New-Object System.Collections.ArrayList
|
||||||
$resultingMatches = [Regex]::Matches($repo, $regex, "IgnoreCase")
|
$resultingMatches = [Regex]::Matches($repo, $regex, "IgnoreCase")
|
||||||
foreach($match in $resultingMatches)
|
foreach($match in $resultingMatches) {
|
||||||
{
|
|
||||||
$cleanedMatch = $match.Groups[1].Value.Trim()
|
$cleanedMatch = $match.Groups[1].Value.Trim()
|
||||||
[void] $returnMatches.Add($cleanedMatch)
|
[void] $returnMatches.Add($cleanedMatch)
|
||||||
}
|
}
|
||||||
if ($arch -eq 'x86') {$returnMatches = $returnMatches | Where {$_ -like "Salt-Minion*x86-Setup.exe"}}
|
If ($arch -eq 'x86') {
|
||||||
else {$returnMatches = $returnMatches | Where {$_ -like "Salt-Minion*AMD64-Setup.exe"}}
|
$returnMatches = $returnMatches | Where {$_ -like "Salt-Minion*x86-Setup.exe"}
|
||||||
|
}
|
||||||
$version = $(($returnMatches | Sort-Object -Descending)[0]).Split(("n-","-A","-x"),([System.StringSplitOptions]::RemoveEmptyEntries))[1]
|
Else {
|
||||||
|
$returnMatches = $returnMatches | Where {$_ -like "Salt-Minion*AMD64-Setup.exe"}
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $(($returnMatches | Sort-Object -Descending)[0]).Split(("n-","-A","-x"),([System.StringSplitOptions]::RemoveEmptyEntries))[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
# Download minion setup file
|
# Download minion setup file
|
||||||
Write-Output -NoNewline "Downloading Salt minion installer Salt-Minion-$version-$arch-Setup.exe"
|
#===============================================================================
|
||||||
|
Write-Output "Downloading Salt minion installer Salt-Minion-$version-$arch-Setup.exe"
|
||||||
$webclient = New-Object System.Net.WebClient
|
$webclient = New-Object System.Net.WebClient
|
||||||
$url = "https://repo.saltstack.com/windows/Salt-Minion-$version-$arch-Setup.exe"
|
$url = "$repourl/Salt-Minion-$version-$arch-Setup.exe"
|
||||||
$file = "C:\tmp\salt.exe"
|
$file = "C:\tmp\salt.exe"
|
||||||
$webclient.DownloadFile($url, $file)
|
$webclient.DownloadFile($url, $file)
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Set the parameters for the installer
|
||||||
|
#===============================================================================
|
||||||
|
# Unless specified, use the installer defaults
|
||||||
|
# - id: <hostname>
|
||||||
|
# - master: salt
|
||||||
|
# - Start the service
|
||||||
|
$parameters = ""
|
||||||
|
If($minion -ne "not-specified") {$parameters = "/minion-name=$minion"}
|
||||||
|
If($master -ne "not-specified") {$parameters = "$parameters /master=$master"}
|
||||||
|
If($runservice -eq $false) {$parameters = "$parameters /start-service=0"}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
# Install minion silently
|
# Install minion silently
|
||||||
Write-Output -NoNewline "Installing Salt minion"
|
#===============================================================================
|
||||||
#Wait for process to exit before continuing.
|
#Wait for process to exit before continuing.
|
||||||
C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null
|
Write-Output "Installing Salt minion"
|
||||||
|
Start-Process C:\tmp\salt.exe -ArgumentList "/S $parameters" -Wait -NoNewWindow -PassThru | Out-Null
|
||||||
|
|
||||||
# Check if minion config has been uploaded
|
|
||||||
If (Test-Path C:\tmp\minion) {
|
|
||||||
cp C:\tmp\minion C:\salt\conf\
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Configure the minion service
|
||||||
|
#===============================================================================
|
||||||
# Wait for salt-minion service to be registered before trying to start it
|
# Wait for salt-minion service to be registered before trying to start it
|
||||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||||
While (!$service) {
|
While (!$service) {
|
||||||
|
@ -150,30 +253,33 @@ While (!$service) {
|
||||||
}
|
}
|
||||||
|
|
||||||
If($runservice) {
|
If($runservice) {
|
||||||
# Start service
|
# 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
|
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
|
# Check if service is started, otherwise retry starting the
|
||||||
# went wrong and user intervention is required - report failure.
|
# service 4 times.
|
||||||
If ($service.Status -eq "Stopped") {
|
$try = 0
|
||||||
Write-Output -NoNewline "Failed to start salt minion"
|
While (($service.Status -ne "Running") -and ($try -ne 4)) {
|
||||||
exit 1
|
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-Output -NoNewline "Failed to start salt minion"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
Write-Output -NoNewline "Stopping salt minion and setting it to 'Manual'"
|
Write-Output -NoNewline "Stopping salt minion and setting it to 'Manual'"
|
||||||
Set-Service "salt-minion" -startupType "Manual"
|
Set-Service "salt-minion" -StartupType "Manual"
|
||||||
Stop-Service "salt-minion"
|
Stop-Service "salt-minion"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Script Complete
|
||||||
|
#===============================================================================
|
||||||
Write-Output "Salt minion successfully installed"
|
Write-Output "Salt minion successfully installed"
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue