e012c2b5bf
Includes: * baseline Windows AMI * initial pass at Terraform configurations * OpenSSH for Windows Using OpenSSH is a lot nicer for Nomad developers than winrm would be, plus it lets us avoid passing around the Windows password in the clear. Note that now we're copying up all the provisioning scripts and configs as a zipped bundle because TF's file provisioner dies in the middle of pushing up multiple files (whereas `scp -r` works fine). We're also running all the provisioning scripts inside the userdata by polling for the zip file to show up (gross!). This is because `remote-exec` provisioners are failing on Windows with the same symptoms as: https://github.com/hashicorp/terraform/issues/17728 If we can't fix this, it'll prevent us from having multiple Windows clients running until TF supports count interpolation in the `template_file`, which is planned for a later 0.12 release.
31 lines
906 B
PowerShell
Executable file
31 lines
906 B
PowerShell
Executable file
$RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
|
if (!$RunningAsAdmin) {
|
|
Write-Error "Must be executed in Administrator level shell."
|
|
exit 1
|
|
}
|
|
|
|
$service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"'
|
|
|
|
if (!$service) {
|
|
Write-Error "Failed to retrieve the wauserv service"
|
|
exit 1
|
|
}
|
|
|
|
if ($service.StartMode -ne "Disabled") {
|
|
$result = $service.ChangeStartMode("Disabled").ReturnValue
|
|
if($result) {
|
|
Write-Error "Failed to disable the 'wuauserv' service. The return value was $result."
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
if ($service.State -eq "Running") {
|
|
$result = $service.StopService().ReturnValue
|
|
if ($result) {
|
|
Write-Error "Failed to stop the 'wuauserv' service. The return value was $result."
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Write-Output "Automatic Windows Updates disabled."
|