github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/terraform/provision-nomad/install-windows.tf (about) 1 resource "null_resource" "install_nomad_binary_windows" { 2 count = var.platform == "windows" ? 1 : 0 3 triggers = { nomad_binary_sha = filemd5(var.nomad_local_binary) } 4 5 connection { 6 type = "ssh" 7 user = var.connection.user 8 host = var.instance.public_ip 9 port = var.connection.port 10 private_key = file(var.connection.private_key) 11 target_platform = "windows" 12 timeout = "10m" 13 } 14 15 provisioner "file" { 16 source = var.nomad_local_binary 17 destination = "/tmp/nomad" 18 } 19 provisioner "remote-exec" { 20 inline = [ 21 "powershell Move-Item -Force -Path C://tmp/nomad -Destination C:/opt/nomad.exe", 22 ] 23 } 24 } 25 26 resource "null_resource" "install_consul_configs_windows" { 27 count = var.platform == "windows" ? 1 : 0 28 29 depends_on = [ 30 null_resource.upload_consul_configs, 31 ] 32 33 connection { 34 type = "ssh" 35 user = var.connection.user 36 host = var.instance.public_ip 37 port = var.connection.port 38 private_key = file(var.connection.private_key) 39 target_platform = "windows" 40 timeout = "10m" 41 } 42 43 provisioner "remote-exec" { 44 inline = [ 45 "powershell Remove-Item -Force -Recurse -Path C://etc/consul.d", 46 "powershell New-Item -Force -Path C:// -Name opt -ItemType directory", 47 "powershell New-Item -Force -Path C://etc -Name consul.d -ItemType directory", 48 "powershell Move-Item -Force -Path C://tmp/consul_ca.pem C://Windows/System32/ca.pem", 49 "powershell Move-Item -Force -Path C://tmp/consul_client_acl.json C://etc/consul.d/acl.json", 50 "powershell Move-Item -Force -Path C://tmp/consul_client.json C://etc/consul.d/consul_client.json", 51 "powershell Move-Item -Force -Path C://tmp/consul_client_base.json C://etc/consul.d/consul_client_base.json", 52 ] 53 } 54 } 55 56 resource "null_resource" "install_nomad_configs_windows" { 57 count = var.platform == "windows" ? 1 : 0 58 59 depends_on = [ 60 null_resource.upload_nomad_configs, 61 ] 62 63 connection { 64 type = "ssh" 65 user = var.connection.user 66 host = var.instance.public_ip 67 port = var.connection.port 68 private_key = file(var.connection.private_key) 69 target_platform = "windows" 70 timeout = "10m" 71 } 72 73 provisioner "remote-exec" { 74 inline = [ 75 "powershell Remove-Item -Force -Recurse -Path C://etc/nomad.d", 76 "powershell New-Item -Force -Path C:// -Name opt -ItemType directory", 77 "powershell New-Item -Force -Path C:// -Name etc -ItemType directory", 78 "powershell New-Item -Force -Path C://etc/ -Name nomad.d -ItemType directory", 79 "powershell New-Item -Force -Path C://opt/ -Name nomad -ItemType directory", 80 "powershell New-Item -Force -Path C://opt/nomad -Name data -ItemType directory", 81 "powershell Move-Item -Force -Path C://tmp/consul.hcl C://etc/nomad.d/consul.hcl", 82 "powershell Move-Item -Force -Path C://tmp/vault.hcl C://etc/nomad.d/vault.hcl", 83 "powershell Move-Item -Force -Path C://tmp/base.hcl C://etc/nomad.d/base.hcl", 84 "powershell Move-Item -Force -Path C://tmp/${var.role}-${var.platform}.hcl C://etc/nomad.d/${var.role}-${var.platform}.hcl", 85 "powershell Move-Item -Force -Path C://tmp/${var.role}-${var.platform}-${var.index}.hcl C://etc/nomad.d/${var.role}-${var.platform}-${var.index}.hcl", 86 "powershell Move-Item -Force -Path C://tmp/.environment C://etc/nomad.d/.environment", 87 88 # TLS 89 "powershell New-Item -Force -Path C://etc/nomad.d -Name tls -ItemType directory", 90 "powershell Move-Item -Force -Path C://tmp/tls.hcl C://etc/nomad.d/tls.hcl", 91 "powershell Move-Item -Force -Path C://tmp/agent-${var.instance.public_ip}.key C://etc/nomad.d/tls/agent.key", 92 "powershell Move-Item -Force -Path C://tmp/agent-${var.instance.public_ip}.crt C://etc/nomad.d/tls/agent.crt", 93 "powershell Move-Item -Force -Path C://tmp/ca.crt C://etc/nomad.d/tls/ca.crt", 94 ] 95 } 96 } 97 98 resource "null_resource" "restart_windows_services" { 99 count = var.platform == "windows" ? 1 : 0 100 101 depends_on = [ 102 null_resource.install_nomad_binary_windows, 103 null_resource.install_consul_configs_windows, 104 null_resource.install_nomad_configs_windows, 105 ] 106 107 connection { 108 type = "ssh" 109 user = var.connection.user 110 host = var.instance.public_ip 111 port = var.connection.port 112 private_key = file(var.connection.private_key) 113 target_platform = "windows" 114 timeout = "10m" 115 } 116 117 provisioner "remote-exec" { 118 inline = [ 119 "powershell Restart-Service Consul", 120 "powershell Restart-Service Nomad" 121 ] 122 } 123 }