Skip to content

Commit

Permalink
style: add an output with the custer identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Jan 17, 2025
1 parent 9d5c750 commit 01d5601
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
5 changes: 3 additions & 2 deletions e2e/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,21 @@ about the cluster:
client node IPs.
- `terraform output windows_clients` will output the list of Windows
client node IPs.
- `cluster_unique_identifier` will output the random name used to identify the cluster's resources

## SSH

You can use Terraform outputs above to access nodes via ssh:

```sh
ssh -i keys/{cluster-name}/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR}
ssh -i keys/${CLUSTER_UNIQUE_IDENTIFIER}/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR}
```

The Windows client runs OpenSSH for convenience, but has a different
user and will drop you into a Powershell shell instead of bash:

```sh
ssh -i keys/{cluster-name}/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR}
ssh -i keys/${CLUSTER_UNIQUE_IDENTIFIER}/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR}
```

## Teardown
Expand Down
6 changes: 5 additions & 1 deletion e2e/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ output "nomad_token" {
sensitive = true
}

output "cluster_unique_identifier" {
value = module.provision-infra.cluster_unique_identifier
}

# Note: Consul and Vault environment needs to be set in test
# environment before the Terraform run, so we don't have that output
# here
output "environment" {
description = "get connection config by running: $(terraform output environment)"
sensitive = true
value = module.provision-infra.environment
}
}
5 changes: 5 additions & 0 deletions e2e/terraform/provision-infra/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ 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(local.keys_dir)}/tls_ca.crt
export CLUSTER_UNIQUE_IDENTIFIER=${local.random_name}
EOM
}

output "cluster_unique_identifier" {
value = "${local.random_name}"
}

output "nomad_addr" {
value = "https://${aws_instance.server[0].public_ip}:4646"
}
Expand Down
25 changes: 25 additions & 0 deletions enos/modules/fetch_artifactory/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

output "nomad_local_binary" {
value = "${var.binary_path}/nomad"
description = "Path where the binary will be placed"
}

output "vault_artifactory_release" {
description = "Binary information returned from the artifactory"
value = {
url = data.enos_artifactory_item.nomad.results[0].url
sha256 = data.enos_artifactory_item.nomad.results[0].sha256
}
}

output "nomad_local_binary_ubuntu_jammy" {
value = "${var.binary_path}/nomad"
description = "Path where the binary will be placed"
}

output "nomad_local_binary_windows_2016" {
value = "${var.binary_path}/nomad.exe"
description = "Path where the binary will be placed"
}
25 changes: 25 additions & 0 deletions enos/modules/run_workloads/scripts/wait_for_nomad_api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

set -xeuo pipefail

TIMEOUT=15
INTERVAL=5

start_time=$(date +%s)

while ! nomad server members > /dev/null 2>&1; do
echo "Waiting for Nomad API..."

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
echo "Error: Nomad API did not become available within $TIMEOUT seconds."
exit 1
fi

sleep "$INTERVAL"
done

echo "Nomad API is available!"

0 comments on commit 01d5601

Please sign in to comment.