diff --git a/jobs/fastcgi.nomad b/jobs/fastcgi.nomad index 98f6d2f..7154b28 100644 --- a/jobs/fastcgi.nomad +++ b/jobs/fastcgi.nomad @@ -4,7 +4,12 @@ variable "test" { default = false } -variable "main_nomad_addr" { +variable "main_nomad_private_ip" { + type = string + default = "" +} + +variable "test_nomad_public_ip" { type = string default = "" } @@ -20,11 +25,6 @@ variable "test_include_mysql" { default = false } -variable "test_nomad_addr" { - type = string - default = "" -} - locals { main = !var.test } @@ -74,7 +74,7 @@ job "fastcgi" { args = [ "-c", var.test_include_mysql ? "echo -n 'Waiting for service'; until nslookup mysql.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done" - : "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_addr} 3306 < /dev/null; do echo '.'; sleep 2; done", + : "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_private_ip} 3306 < /dev/null; do echo '.'; sleep 2; done", ] } @@ -254,9 +254,9 @@ job "fastcgi" { MEDIAWIKI_SKIP_IMPORT_SITES = "1" MEDIAWIKI_SKIP_UPDATE = "0" - MEDIAWIKI_SERVER = "http://${var.test_nomad_addr}" + MEDIAWIKI_SERVER = "http://${var.test_nomad_public_ip}" - WG_DB_SERVER = var.test_include_mysql ? NOMAD_UPSTREAM_ADDR_mysql : var.main_nomad_addr + WG_DB_SERVER = var.test_include_mysql ? NOMAD_UPSTREAM_ADDR_mysql : "${var.main_nomad_private_ip}:3306" WG_DB_USER = "mediawiki" WG_DB_PASSWORD = var.mysql_password_mediawiki } diff --git a/jobs/http.nomad b/jobs/http.nomad index 31ab152..d6ffbfd 100644 --- a/jobs/http.nomad +++ b/jobs/http.nomad @@ -4,7 +4,7 @@ variable "test" { default = false } -variable "test_nomad_addr" { +variable "test_nomad_public_ip" { type = string default = "" } @@ -115,9 +115,9 @@ job "http" { dynamic "env" { for_each = var.test ? [{}] : [] content { - CADDYPATH = "/etc/caddycerts" - FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000" - TEST_NOMAD_ADDR = var.test_nomad_addr + CADDYPATH = "/etc/caddycerts" + FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000" + TEST_NOMAD_PUBLIC_IP = var.test_nomad_public_ip } } @@ -193,7 +193,7 @@ variable "caddyfile_for_test" { auto_https off order mwcache before rewrite } -http://127.0.0.1:80 http://localhost:80 http://{$TEST_NOMAD_ADDR}:80 +http://127.0.0.1:80 http://localhost:80 http://{$TEST_NOMAD_PUBLIC_IP}:80 root * /srv/femiwiki.com php_fastcgi {$FASTCGI_ADDR} file_server diff --git a/terraform/base.tf b/terraform/base.tf index 05d83bb..242072a 100644 --- a/terraform/base.tf +++ b/terraform/base.tf @@ -51,7 +51,7 @@ provider "nomad" { provider "nomad" { alias = "test" - address = data.terraform_remote_state.aws.outputs.test_nomad_addr + address = "http://${data.terraform_remote_state.aws.outputs.test_nomad_public_ip}:4646" secret_id = var.test_nomad_token consul_token = var.test_consul_token region = "global" diff --git a/terraform/mediawiki.tf b/terraform/mediawiki.tf index 70f6cdf..2a6bab9 100644 --- a/terraform/mediawiki.tf +++ b/terraform/mediawiki.tf @@ -61,9 +61,9 @@ resource "nomad_job" "test_fastcgi" { allow_fs = true vars = { test = true - main_nomad_addr = data.terraform_remote_state.aws.outputs.nomad_addr + main_nomad_private_ip = data.terraform_remote_state.aws.outputs.nomad_private_ip mysql_password_mediawiki = var.mysql_password_mediawiki - test_nomad_addr = data.terraform_remote_state.aws.outputs.test_nomad_addr + test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip test_include_mysql = false } } @@ -97,8 +97,8 @@ resource "nomad_job" "test_http" { hcl2 { allow_fs = true vars = { - test = true - test_nomad_addr = data.terraform_remote_state.aws.outputs.test_nomad_addr + test = true + test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip } } }