Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: use a variable for region #24693

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading