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