-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaltminion_packer_immutable.ps1
28 lines (25 loc) · 1.07 KB
/
saltminion_packer_immutable.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string]$MasterHost = "not-specified",
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string]$nms_app_zip = "not-specified"
)
Write-Verbose 'Configuring Salt... please wait'
$ConfigFile = 'C:\salt\conf\minion'
$IdFile = 'C:\salt\conf\minion_id'
$minionId = $env:COMPUTERNAME.ToLower()
$nms_app_id = $nms_app_zip
$grainString = @"
grains:
nms_app_id: $nms_app_id
deployment_method: packer_post_deploy
"@
Set-Content $ConfigFile "master: $MasterHost"
Add-Content $ConfigFile "startup_states: highstate"
Add-Content $ConfigFile $grainString
Set-Content $IdFile "$minionId"
Remove-Item -Path C:\salt\conf\minion.d\f_defaults.conf -Force
Set-Service "salt-minion" -StartupType "Automatic"
Start-Service "salt-minion"
Start-Process powershell { c:\salt\salt-call.bat state.highstate -l debug; Start-ScheduledTask -TaskName InstallWindowsUpdates; Start-ScheduledTask -TaskName InstallPSWinUpdate; Install-WindowsUpdate -IgnoreUserInput -AcceptAll -IgnoreReboot -verbose }
c:\salt\salt-call.bat system.reboot 12