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.
36 lines
1.1 KiB
PowerShell
Executable file
36 lines
1.1 KiB
PowerShell
Executable file
Set-StrictMode -Version latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$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
|
|
}
|
|
|
|
# Force TLS1.2
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
Try {
|
|
Write-Output "Installing containers feature."
|
|
Install-WindowsFeature -Name Containers
|
|
|
|
Write-Output "Creating user for Docker."
|
|
net localgroup docker /add
|
|
net localgroup docker $env:USERNAME /add
|
|
|
|
Write-Output "Installing Docker."
|
|
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
|
|
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
|
|
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
|
|
|
|
} Catch {
|
|
Write-Error "Failed to install Docker."
|
|
$host.SetShouldExit(-1)
|
|
throw
|
|
} Finally {
|
|
# clean up by re-securing this package repo
|
|
Set-PSRepository -InstallationPolicy Untrusted -Name PSGallery
|
|
}
|
|
|
|
Write-Output "Installed Docker."
|