mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
feat(ps1): implement configure only option (for Vagrant)
This commit is contained in:
parent
fe832d0eb1
commit
6510a2f44a
1 changed files with 79 additions and 59 deletions
|
@ -99,6 +99,9 @@ Param(
|
|||
|
||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||
[string]$repourl= "https://repo.saltproject.io/windows"
|
||||
|
||||
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
|
||||
[switch]$ConfigureOnly
|
||||
)
|
||||
|
||||
# Powershell supports only TLS 1.0 by default. Add support for TLS 1.2
|
||||
|
@ -181,6 +184,9 @@ Else {
|
|||
#===============================================================================
|
||||
# Ensure Directories are present, copy Vagrant Configs if found
|
||||
#===============================================================================
|
||||
|
||||
$ConfiguredAnything = $False
|
||||
|
||||
# Create C:\tmp\
|
||||
New-Item C:\tmp\ -ItemType directory -Force | Out-Null
|
||||
|
||||
|
@ -192,6 +198,7 @@ If (Test-Path C:\tmp\minion.pem) {
|
|||
# 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\
|
||||
$ConfiguredAnything = $True
|
||||
}
|
||||
|
||||
# Check if minion config has been uploaded
|
||||
|
@ -200,6 +207,12 @@ If (Test-Path C:\tmp\minion.pem) {
|
|||
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
|
||||
$ConfiguredAnything = $True
|
||||
}
|
||||
|
||||
If ($ConfigureOnly -and !$ConfiguredAnything) {
|
||||
Write-Output "No configuration or keys were copied over. No configuration was done!"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
@ -229,6 +242,7 @@ If ((!$version) -or ($version.ToLower() -eq 'latest')){
|
|||
}
|
||||
}
|
||||
|
||||
If (!$ConfigureOnly) {
|
||||
#===============================================================================
|
||||
# Download minion setup file
|
||||
#===============================================================================
|
||||
|
@ -295,8 +309,14 @@ Else {
|
|||
Set-Service "salt-minion" -StartupType "Manual"
|
||||
Stop-Service "salt-minion"
|
||||
}
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
# Script Complete
|
||||
#===============================================================================
|
||||
If ($ConfigureOnly) {
|
||||
Write-Output "Salt minion successfully configured"
|
||||
}
|
||||
Else {
|
||||
Write-Output "Salt minion successfully installed"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue