Skip to content

Commit

Permalink
func: add single binary for servers in the provision module
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Feb 12, 2025
1 parent 361c417 commit 7157cbd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
6 changes: 5 additions & 1 deletion e2e/terraform/provision-infra/nomad.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

locals {
server_binary = var.nomad_local_binary_server_unique == "" ? var.nomad_local_binary : var.nomad_local_binary_server_unique
}

module "nomad_server" {
source = "./provision-nomad"
depends_on = [aws_instance.server]
Expand All @@ -13,7 +17,7 @@ module "nomad_server" {
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_local_binary = count.index < length(var.nomad_local_binary_server) ? var.nomad_local_binary_server[count.index] : local.server_binary

nomad_license = var.nomad_license
tls_ca_key = tls_private_key.ca.private_key_pem
Expand Down
6 changes: 6 additions & 0 deletions e2e/terraform/provision-infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ variable "aws_kms_alias" {
# provide a list of builds to override the values of nomad_sha, nomad_version,
# or nomad_local_binary. Most of the time you can ignore these variables!

variable "nomad_local_binary_server_unique" {
description = "A nomad local binary paths to deploy to servers, to override nomad_local_binary"
type = string
default = ""
}

variable "nomad_local_binary_server" {
description = "A list of nomad local binary paths to deploy to servers, to override nomad_local_binary"
type = list(string)
Expand Down
2 changes: 1 addition & 1 deletion enos/enos-modules.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

module "fetch_artifactory" {
module "install_binaries" {
source = "./modules/install_binaries"
}

Expand Down
36 changes: 18 additions & 18 deletions enos/enos-scenario-upgrade.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ scenario "upgrade" {
clients_count = local.linux_count + local.windows_count
test_product_version = matrix.edition == "ent" ? "${var.product_version}+ent" : "${var.product_version}"
test_upgrade_version = matrix.edition == "ent" ? "${var.upgrade_version}+ent" : "${var.upgrade_version}"
necessary_binaries = matrix.os == "windows" ? ["linux", "windows"] : ["linux"]
server_os = "linux"
download_binaries_path = "${var.download_binary_path}/${matrix.arch}-${matrix.edition}-${var.product_version}"
}

Expand All @@ -44,19 +44,19 @@ scenario "upgrade" {
running enos.
EOF

module = module.fetch_artifactory
module = module.install_binaries

variables {
artifactory_username = var.artifactory_username
artifactory_token = var.artifactory_token
arch = local.arch
edition = matrix.edition
product_version = var.product_version
oss = local.necessary_binaries
oss = [local.server_os, matrix.os]
download_binaries_path = local.download_binaries_path
}
}
/*

step "provision_cluster" {
depends_on = [step.copy_initial_binary]

Expand All @@ -67,20 +67,20 @@ scenario "upgrade" {

module = module.provision_cluster
variables {
name = local.cluster_name
nomad_local_binary = step.copy_initial_binary.nomad_local_binary
nomad_local_binary_server = step.copy_initial_binary.nomad_local_binary
server_count = var.server_count
client_count_linux = local.linux_count
client_count_windows_2016 = local.windows_count
nomad_license = var.nomad_license
consul_license = var.consul_license
volumes = false
region = var.aws_region
instance_arch = matrix.arch
name = local.cluster_name
nomad_local_binary = step.copy_initial_binary.binary_path_per_os[matrix.os]
nomad_local_binary_server_unique = step.copy_initial_binary.binary_path_per_os[local.server_os]
server_count = var.server_count
client_count_linux = local.linux_count
client_count_windows_2016 = local.windows_count
nomad_license = var.nomad_license
consul_license = var.consul_license
volumes = false
region = var.aws_region
instance_arch = matrix.arch
}
}
/*
step "run_initial_workloads" {
depends_on = [step.provision_cluster]
Expand Down Expand Up @@ -367,8 +367,8 @@ scenario "upgrade" {
sensitive = true
} */

output "nomad_binary_info_map" {
value = step.copy_initial_binary.nomad_binary_info_map
output "binary_info_per_os" {
value = step.copy_initial_binary.binary_path_per_os
sensitive = true
}
}
22 changes: 16 additions & 6 deletions enos/modules/install_binaries/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

output "nomad_binary_info_map" {
output "binary_path_per_os" {
description = "Map containing information about the Nomad binary for each of the requested OSs"
value = {
for os in var.oss : os => {
path = module.fetch_artifact[os].nomad_local_binary
artifact_url = module.fetch_artifact[os].artifact_url
artifact_sha = module.fetch_artifact[os].artifact_sha
}
for os in var.oss : os => module.fetch_artifact[os].nomad_local_binary
}
}

output "artifact_url_per_os" {
description = "Map containing information about the Nomad binary for each of the requested OSs"
value = {
for os in var.oss : os => module.fetch_artifact[os].artifact_sha
}
}

output "artifact_sha_per_os" {
description = "Map containing information about the Nomad binary for each of the requested OSs"
value = {
for os in var.oss : os => module.fetch_artifact[os].artifact_sha
}
}

0 comments on commit 7157cbd

Please sign in to comment.