github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/terraform/packer/windows-2016-amd64/install-nomad.ps1 (about) 1 Set-StrictMode -Version latest 2 $ErrorActionPreference = "Stop" 3 4 # Force TLS1.2 5 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 6 7 Set-Location C:\opt 8 9 Try { 10 $releases = "https://releases.hashicorp.com" 11 $version = "1.2.6" 12 $url = "${releases}/nomad/${version}/nomad_${version}_windows_amd64.zip" 13 14 New-Item -ItemType Directory -Force -Path C:\opt\nomad 15 New-Item -ItemType Directory -Force -Path C:\etc\nomad.d 16 17 # TODO: check sha! 18 Write-Output "Downloading Nomad from: $url" 19 Invoke-WebRequest -Uri $url -Outfile nomad.zip -ErrorAction Stop 20 Expand-Archive .\nomad.zip .\ -ErrorAction Stop 21 Move-Item nomad.exe C:\opt\nomad.exe -Force -ErrorAction Stop 22 C:\opt\nomad.exe version 23 rm nomad.zip 24 25 New-NetFirewallRule ` 26 -DisplayName 'Nomad HTTP Inbound' ` 27 -Profile @('Public', 'Domain', 'Private') ` 28 -Direction Inbound ` 29 -Action Allow ` 30 -Protocol TCP ` 31 -LocalPort @('4646') 32 33 New-Service ` 34 -Name "Nomad" ` 35 -BinaryPathName "C:\opt\nomad.exe agent -config C:\etc\nomad.d" ` 36 -StartupType "Automatic" ` 37 -ErrorAction Ignore 38 39 } Catch { 40 Write-Output "Failed to install Nomad." 41 Write-Output $_ 42 $host.SetShouldExit(-1) 43 throw 44 } 45 46 Write-Output "Installed Nomad."