Skip to content

Commit

Permalink
func: make paths relative to the module inside the e2e terraform folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Dec 5, 2024
1 parent 61f7a0a commit 2dbb489
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion e2e/terraform/consul.hclic

This file was deleted.

6 changes: 3 additions & 3 deletions e2e/terraform/nomad-acls.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "null_resource" "bootstrap_nomad_acls" {

data "local_sensitive_file" "nomad_token" {
depends_on = [null_resource.bootstrap_nomad_acls]
filename = "${path.root}/keys/nomad_root_token"
filename = "${path.module}/keys/nomad_root_token"
}

# push the token out to the servers for humans to use.
Expand All @@ -36,8 +36,8 @@ locals {
cat <<ENV | sudo tee -a /root/.bashrc
export NOMAD_ADDR=https://localhost:4646
export NOMAD_SKIP_VERIFY=true
export NOMAD_CLIENT_CERT=/etc/nomad.d/tls/agent.crt
export NOMAD_CLIENT_KEY=/etc/nomad.d/tls/agent.key
export NOMAD_CLIENT_CERT="${path.module}/etc/nomad.d/tls/agent.crt"
export NOMAD_CLIENT_KEY="${path.module}/etc/nomad.d/tls/agent.key"
export NOMAD_TOKEN=${data.local_sensitive_file.nomad_token.content}
export CONSUL_HTTP_ADDR=https://localhost:8501
export CONSUL_HTTP_TOKEN="${random_uuid.consul_initial_management_token.result}"
Expand Down
1 change: 0 additions & 1 deletion e2e/terraform/nomad.hclic

This file was deleted.

11 changes: 5 additions & 6 deletions e2e/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ output "environment" {
sensitive = true
value = <<EOM
export NOMAD_ADDR=https://${aws_instance.server[0].public_ip}:4646
export NOMAD_CACERT=${abspath(path.root)}/keys/tls_ca.crt
export NOMAD_CLIENT_CERT=${abspath(path.root)}/keys/tls_api_client.crt
export NOMAD_CLIENT_KEY=${abspath(path.root)}/keys/tls_api_client.key
export NOMAD_CACERT=${abspath(path.module)}/keys/tls_ca.crt
export NOMAD_CLIENT_CERT=${abspath(path.module)}/keys/tls_api_client.crt
export NOMAD_CLIENT_KEY=${abspath(path.module)}/keys/tls_api_client.key
export NOMAD_TOKEN=${data.local_sensitive_file.nomad_token.content}
export NOMAD_E2E=1
export CONSUL_HTTP_ADDR=https://${aws_instance.consul_server.public_ip}:8501
export CONSUL_HTTP_TOKEN=${local_sensitive_file.consul_initial_management_token.content}
export CONSUL_CACERT=${abspath(path.root)}/keys/tls_ca.crt
export CONSUL_CACERT=${abspath(path.module)}/keys/tls_ca.crt
EOM
}
}
2 changes: 1 addition & 1 deletion e2e/terraform/provision-nomad/install-linux.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: BUSL-1.1

resource "local_sensitive_file" "nomad_systemd_unit_file" {
content = templatefile("etc/nomad.d/nomad-${var.role}.service", {})
content = templatefile("${path.module}/etc/nomad.d/nomad-${var.role}.service", {})
filename = "${local.upload_dir}/nomad.d/nomad.service"
file_permission = "0600"
}
Expand Down
5 changes: 2 additions & 3 deletions e2e/terraform/provision-nomad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
locals {
upload_dir = "uploads/${var.instance.public_ip}"

indexed_config_path = fileexists("etc/nomad.d/${var.role}-${var.platform}-${var.index}.hcl") ? "etc/nomad.d/${var.role}-${var.platform}-${var.index}.hcl" : "etc/nomad.d/index.hcl"

indexed_config_path = fileexists("${path.module}/etc/nomad.d/${var.role}-${var.platform}-${var.index}.hcl") ? "${path.module}/etc/nomad.d/${var.role}-${var.platform}-${var.index}.hcl" : "${path.module}/etc/nomad.d/index.hcl"
}

# if nomad_license is unset, it'll be a harmless empty license file
Expand All @@ -26,7 +25,7 @@ resource "local_sensitive_file" "nomad_base_config" {
}

resource "local_sensitive_file" "nomad_role_config" {
content = templatefile("etc/nomad.d/${var.role}-${var.platform}.hcl", {
content = templatefile("${path.module}/etc/nomad.d/${var.role}-${var.platform}.hcl", {
aws_region = var.aws_region
aws_kms_key_id = var.aws_kms_key_id
})
Expand Down

0 comments on commit 2dbb489

Please sign in to comment.