Merge pull request #5980 from PatOShea/PatOShea-ConfigDir-Typo

Fixed salt minion configuration directory typo
This commit is contained in:
Mitchell Hashimoto 2015-07-17 12:37:44 -07:00
commit 4b217e2128
4 changed files with 115 additions and 39 deletions

View File

@ -1,12 +1,34 @@
Param( Param(
[string]$version [string]$version,
[string]$runservice,
[string]$minion,
[string]$master
) )
# Salt version to install - default to latest if there is an issue # Constants
if ($version -notmatch "201[0-9]\.[0-9]\.[0-9](\-\d{1})?"){ $ServiceName = "salt-minion"
$startupType = "Manual"
# Version to install - default to latest if there is an issue
If ($version -notmatch "201[0-9]\.[0-9]\.[0-9](\-\d{1})?"){
$version = '2015.5.2' $version = '2015.5.2'
} }
If ($runservice.ToLower() -eq "true"){
Write-Host "Service is set to run."
[bool]$runservice = $True
}
ElseIf ($runservice.ToLower() -eq "false"){
Write-Host "Service will be stopped and set to manual."
[bool]$runservice = $False
}
Else {
# Param passed in wasn't clear so defaulting to true.
Write-Host "Service defaulting to run."
[bool]$runservice = $True
}
# Create C:\tmp\ - if Vagrant doesn't upload keys and/or config it might not exist # 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 New-Item C:\tmp\ -ItemType directory -force | out-null
@ -14,32 +36,48 @@ New-Item C:\tmp\ -ItemType directory -force | out-null
New-Item C:\salt\conf\pki\minion\ -ItemType directory -force | out-null New-Item C:\salt\conf\pki\minion\ -ItemType directory -force | out-null
# Check if minion keys have been uploaded # 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\ cp C:\tmp\minion.pem C:\salt\conf\pki\minion\
cp C:\tmp\minion.pub C:\salt\conf\pki\minion\ cp C:\tmp\minion.pub C:\salt\conf\pki\minion\
} }
# Detect architecture # Detect architecture
if ([IntPtr]::Size -eq 4) { If ([IntPtr]::Size -eq 4) {
$arch = "x86" $arch = "x86"
} else { } Else {
$arch = "AMD64" $arch = "AMD64"
} }
# Download minion setup file # Download minion setup file
Write-Host "Downloading Salt minion installer $version-$arch..." Write-Host "Downloading Salt minion installer Salt-Minion-$version-$arch-Setup.exe"
$webclient = New-Object System.Net.WebClient $webclient = New-Object System.Net.WebClient
$url = "https://docs.saltstack.com/downloads/Salt-Minion-$version-$arch-Setup.exe" $url = "https://docs.saltstack.com/downloads/Salt-Minion-$version-$arch-Setup.exe"
$file = "C:\tmp\salt.exe" $file = "C:\tmp\salt.exe"
$webclient.DownloadFile($url, $file) $webclient.DownloadFile($url, $file)
# Install minion silently # Install minion silently
Write-Host "Installing Salt minion..." Write-Host "Installing Salt minion..."
#Wait for process to exit before continuing... #Wait for process to exit before continuing...
If($PSBoundParameters.ContainsKey('minion') -and $PSBoundParameters.ContainsKey('master')) {
C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null
Write-Host C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null
}
ElseIf($PSBoundParameters.ContainsKey('minion') -and !$PSBoundParameters.ContainsKey('master')) {
C:\tmp\salt.exe /S /minion-name=$minion | Out-Null
Write-Host C:\tmp\salt.exe /S /minion-name=$minion | Out-Null
}
ElseIf(!$PSBoundParameters.ContainsKey('minion') -and $PSBoundParameters.ContainsKey('master')) {
C:\tmp\salt.exe /S /master=$master | Out-Null
Write-Host C:\tmp\salt.exe /S /master=$master | Out-Null
}
Else {
C:\tmp\salt.exe /S | Out-Null C:\tmp\salt.exe /S | Out-Null
Write-Host C:\tmp\salt.exe /S | Out-Null
}
# Check if minion config has been uploaded # Check if minion config has been uploaded
if (Test-Path C:\tmp\minion) { If (Test-Path C:\tmp\minion) {
cp C:\tmp\minion C:\salt\conf\ cp C:\tmp\minion C:\salt\conf\
} }
@ -50,6 +88,7 @@ While (!$service) {
$service = Get-Service salt-minion -ErrorAction SilentlyContinue $service = Get-Service salt-minion -ErrorAction SilentlyContinue
} }
If($runservice) {
# Start service # Start service
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
@ -65,9 +104,15 @@ While (($service.Status -ne "Running") -and ($try -ne 4)) {
# If the salt-minion service is still not running, something probably # If the salt-minion service is still not running, something probably
# went wrong and user intervention is required - report failure. # went wrong and user intervention is required - report failure.
if ($service.Status -eq "Stopped") { If ($service.Status -eq "Stopped") {
Write-Host "Failed to start Salt minion" Write-Host "Failed to start Salt minion"
exit 1 exit 1
} }
}
Else {
Write-Host "Stopping salt minion"
Set-Service "$ServiceName" -startupType "$startupType"
Stop-Service "$ServiceName"
}
Write-Host "Salt minion successfully installed" Write-Host "Salt minion successfully installed"

View File

@ -37,6 +37,8 @@ module VagrantPlugins
attr_accessor :no_minion attr_accessor :no_minion
attr_accessor :bootstrap_options attr_accessor :bootstrap_options
attr_accessor :version attr_accessor :version
attr_accessor :run_service
attr_accessor :master_id
def initialize def initialize
@minion_config = UNSET_VALUE @minion_config = UNSET_VALUE
@ -67,6 +69,8 @@ module VagrantPlugins
@masterless = UNSET_VALUE @masterless = UNSET_VALUE
@minion_id = UNSET_VALUE @minion_id = UNSET_VALUE
@version = UNSET_VALUE @version = UNSET_VALUE
@run_service = UNSET_VALUE
@master_id = UNSET_VALUE
end end
def finalize! def finalize!
@ -98,6 +102,8 @@ module VagrantPlugins
@masterless = false if @masterless == UNSET_VALUE @masterless = false if @masterless == UNSET_VALUE
@minion_id = nil if @minion_id == UNSET_VALUE @minion_id = nil if @minion_id == UNSET_VALUE
@version = nil if @version == UNSET_VALUE @version = nil if @version == UNSET_VALUE
@run_service = nil if @run_service == UNSET_VALUE
@master_id = nil if @master_id == UNSET_VALUE
end end
def pillar(data) def pillar(data)
@ -110,7 +116,7 @@ module VagrantPlugins
# FIXME: there should be a way to do that a bit smarter # FIXME: there should be a way to do that a bit smarter
if guest_type == :windows if guest_type == :windows
return "C:\\salt" return "C:\\salt\\conf"
else else
return "/etc/salt" return "/etc/salt"
end end

View File

@ -104,7 +104,7 @@ module VagrantPlugins
options = "%s %s" % [options, @config.bootstrap_options] options = "%s %s" % [options, @config.bootstrap_options]
end end
if configure if configure && !@machine.config.vm.communicator == :winrm
options = "%s -F -c %s" % [options, config_dir] options = "%s -F -c %s" % [options, config_dir]
end end
@ -245,7 +245,19 @@ module VagrantPlugins
bootstrap_path = get_bootstrap bootstrap_path = get_bootstrap
if @machine.config.vm.communicator == :winrm if @machine.config.vm.communicator == :winrm
if @config.version if @config.version
options = "-version %s" % @config.version options += " -version %s" % @config.version
end
if @config.run_service
@machine.env.ui.info "Salt minion will be stopped after installing."
options += " -runservice %s" % @config.run_service
end
if @config.minion_id
@machine.env.ui.info "Setting minion to @config.minion_id."
options += " -minion %s" % @config.minion_id
end
if @config.master_id
@machine.env.ui.info "Setting master to @config.master_id."
options += " -master %s" % @config.master_id
end end
bootstrap_destination = File.join(config_dir, "bootstrap_salt.ps1") bootstrap_destination = File.join(config_dir, "bootstrap_salt.ps1")
else else

View File

@ -46,11 +46,10 @@ masterless setup.
## Install Options ## Install Options
* `install_master` (boolean) - Should vagrant install the salt-master * `install_master` (boolean) - Should vagrant install the salt-master
on this machine. Not supported on Windows. on this machine. Not supported on Windows.
* `no_minion` (boolean) - Don't install the minion, default `false` * `no_minion` (boolean) - Don't install the minion, default `false`. Not supported on Windows.
* `install_syndic` (boolean) - Install the salt-syndic, default * `install_syndic` (boolean) - Install the salt-syndic, default
`false`. Not supported on Windows. `false`. Not supported on Windows.
@ -71,11 +70,13 @@ to allow more flexibility with the bootstrap process.
* `always_install` (boolean) - Installs salt binaries even * `always_install` (boolean) - Installs salt binaries even
if they are already detected, default `false` if they are already detected, default `false`
* `bootstrap_script` (string) - Path to your customized salt-bootstrap.sh script. * `bootstrap_script` (string) - Path to your customized salt-bootstrap.sh script. Not supported on Windows.
* `bootstrap_options` (string) - Additional command-line options to * `bootstrap_options` (string) - Additional command-line options to
pass to the bootstrap script. pass to the bootstrap script.
* `version` (string, default: "2015.5.2") - Version of minion to be installed. Only supported on Windows.
## Minion Options ## Minion Options
These only make sense when `no_minion` is `false`. These only make sense when `no_minion` is `false`.
@ -84,20 +85,24 @@ a custom salt minion config file.
* `minion_key` (string) - Path to your minion key * `minion_key` (string) - Path to your minion key
* `minion_id` (string) - Unique identifier for minion. Used for masterless and preseeding keys.
* `minion_pub` (salt/key/minion.pub) - Path to your minion * `minion_pub` (salt/key/minion.pub) - Path to your minion
public key public key
* `grains_config` (string) - Path to a custom salt grains file. * `grains_config` (string) - Path to a custom salt grains file.
* `masterless` (boolean) - Calls state.highstate in local mode. Uses `minion_id` and `pillar_data` when provided.
## Master Options ## Master Options
These only make sense when `install_master` is `true`. These only make sense when `install_master` is `true`. Not supported on Windows.
* `master_config` (string, default: "salt/master") * `master_config` (string, default: "salt/master")
Path to a custom salt master config file Path to a custom salt master config file.
* `master_key` (salt/key/master.pem) - Path to your master key * `master_key` (salt/key/master.pem) - Path to your master key.
* `master_pub` (salt/key/master.pub) - Path to your master public key * `master_pub` (salt/key/master.pub) - Path to your master public key.
* `seed_master` (dictionary) - Upload keys to master, thereby * `seed_master` (dictionary) - Upload keys to master, thereby
pre-seeding it before use. Example: `{minion_name:/path/to/key.pub}` pre-seeding it before use. Example: `{minion_name:/path/to/key.pub}`
@ -109,8 +114,16 @@ during provisioning.
* `run_highstate` - (boolean) Executes `state.highstate` on * `run_highstate` - (boolean) Executes `state.highstate` on
vagrant up. Can be applied to any machine. vagrant up. Can be applied to any machine.
## Execute Runners
Either of the following may be used to actually execute runners
during provisioning.
* `run_overstate` - (boolean) Executes `state.over` on * `run_overstate` - (boolean) Executes `state.over` on
vagrant up. Can be applied to the master only. vagrant up. Can be applied to the master only. This is superceded by orchestrate. Not supported on Windows.
* `orchestrations` - (boolean) Executes `state.orchestrate` on
vagrant up. Can be applied to the master only. This is supercedes by run_overstate. Not supported on Windows.
## Output Control ## Output Control
@ -120,7 +133,7 @@ These may be used to control the output of state execution:
* `log_level` (string) - The verbosity of the outputs. Defaults to "debug". * `log_level` (string) - The verbosity of the outputs. Defaults to "debug".
Can be one of "all", "garbage", "trace", "debug", "info", or Can be one of "all", "garbage", "trace", "debug", "info", or
"warning". "warning". Requires `verbose` to be set to "true".
## Pillar Data ## Pillar Data
@ -154,7 +167,7 @@ times. The data passed in should only be hashes and lists. Here is an example::
## Preseeding Keys ## Preseeding Keys
Preseeding keys is the recommended way to handle provisiong Preseeding keys is the recommended way to handle provisioning
using a master. using a master.
On a machine with salt installed, run On a machine with salt installed, run
`salt-key --gen-keys=[minion_id]` to generate the necessary `salt-key --gen-keys=[minion_id]` to generate the necessary