Skip to content

Commit

Permalink
E2E: use a variable for region (#24693)
Browse files Browse the repository at this point in the history
In #24644 we set the region to "e2e" but forgot to setup the TLS certificate
names appropriately. Swap the region out for a variable instead.
  • Loading branch information
tgross authored Dec 17, 2024
1 parent e48bfec commit abeae5c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions e2e/terraform/nomad.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "nomad_server" {
index = count.index
instance = aws_instance.server[count.index]

nomad_region = var.nomad_region
nomad_local_binary = count.index < length(var.nomad_local_binary_server) ? var.nomad_local_binary_server[count.index] : var.nomad_local_binary

nomad_license = var.nomad_license
Expand Down Expand Up @@ -42,6 +43,7 @@ module "nomad_client_ubuntu_jammy_amd64" {
index = count.index
instance = aws_instance.client_ubuntu_jammy_amd64[count.index]

nomad_region = var.nomad_region
nomad_local_binary = count.index < length(var.nomad_local_binary_client_ubuntu_jammy_amd64) ? var.nomad_local_binary_client_ubuntu_jammy_amd64[count.index] : var.nomad_local_binary

tls_ca_key = tls_private_key.ca.private_key_pem
Expand Down Expand Up @@ -69,6 +71,7 @@ module "nomad_client_windows_2016_amd64" {
index = count.index
instance = aws_instance.client_windows_2016_amd64[count.index]

nomad_region = var.nomad_region
nomad_local_binary = count.index < length(var.nomad_local_binary_client_windows_2016_amd64) ? var.nomad_local_binary_client_windows_2016_amd64[count.index] : ""

tls_ca_key = tls_private_key.ca.private_key_pem
Expand Down
2 changes: 1 addition & 1 deletion e2e/terraform/provision-nomad/etc/nomad.d/base.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

region = "e2e"
region = "${nomad_region}"
bind_addr = "0.0.0.0"
data_dir = "${data_dir}"
enable_debug = true
Expand Down
3 changes: 2 additions & 1 deletion e2e/terraform/provision-nomad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ resource "local_sensitive_file" "nomad_environment" {

resource "local_sensitive_file" "nomad_base_config" {
content = templatefile("${path.module}/etc/nomad.d/base.hcl", {
data_dir = var.platform != "windows" ? "/opt/nomad/data" : "C://opt/nomad/data"
data_dir = var.platform != "windows" ? "/opt/nomad/data" : "C://opt/nomad/data"
nomad_region = var.nomad_region
})
filename = "${local.upload_dir}/nomad.d/base.hcl"
file_permission = "0600"
Expand Down
4 changes: 2 additions & 2 deletions e2e/terraform/provision-nomad/tls.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ resource "tls_private_key" "nomad" {
resource "tls_cert_request" "nomad" {
private_key_pem = tls_private_key.nomad.private_key_pem
ip_addresses = [var.instance.public_ip, var.instance.private_ip, "127.0.0.1"]
dns_names = ["${var.role}.global.nomad"]
dns_names = ["${var.role}.${var.nomad_region}.nomad"]

subject {
common_name = "${var.role}.global.nomad"
common_name = "${var.role}.${var.nomad_region}.nomad"
}
}

Expand Down
6 changes: 6 additions & 0 deletions e2e/terraform/provision-nomad/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

variable "nomad_region" {
type = string
description = "Cluster region"
default = "e2e"
}

variable "nomad_local_binary" {
type = string
description = "Path to local Nomad build (ex. \"/home/me/bin/nomad\")"
Expand Down
4 changes: 2 additions & 2 deletions e2e/terraform/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

# this default tfvars file expects that you have built nomad
# with `make dev` or similar (../../ = this repository root)
# before running `terraform apply` and created the /pkg/goos_goarch/binary
# before running `terraform apply` and created the /pkg/goos_goarch/binary
# folder

nomad_local_binary = "../../pkg/linux_amd64/nomad"
nomad_local_binary_client_windows_2016_amd64 = ["../../pkg/windows_amd64/nomad.exe"]
nomad_local_binary_client_windows_2016_amd64 = ["../../pkg/windows_amd64/nomad.exe"]
5 changes: 5 additions & 0 deletions e2e/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ variable "nomad_license" {
default = ""
}

variable "nomad_region" {
description = "The name of the Nomad region."
default = "e2e"
}

variable "consul_license" {
type = string
description = "If consul_license is set, deploy a license"
Expand Down

0 comments on commit abeae5c

Please sign in to comment.