open-nomad/e2e/terraform/packer/windows/install-vault.ps1
Tim Gross e012c2b5bf
Infrastructure for Windows e2e testing (#6584)
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.
2019-11-19 11:06:10 -05:00

32 lines
753 B
PowerShell
Executable file

Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
# Force TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-Location C:\opt
Try {
$releases = "https://releases.hashicorp.com"
$version = "1.2.3"
$url = "${releases}/vault/${version}/vault_${version}_windows_amd64.zip"
$configDir = "C:\opt\vault.d"
md $configDir
# TODO: check sha!
Write-Output "Downloading Vault from: $url"
Invoke-WebRequest -Uri $url -Outfile vault.zip
Expand-Archive .\vault.zip .\
mv vault.exe C:\opt\vault.exe
C:\opt\vault.exe version
rm vault.zip
} Catch {
Write-Error "Failed to install Vault."
$host.SetShouldExit(-1)
throw
}
Write-Output "Installed Vault."