2023-03-15 16:00:52 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
2023-09-18 21:10:37 +00:00
|
|
|
# SPDX-License-Identifier: BUSL-1.1
|
2023-03-15 16:00:52 +00:00
|
|
|
|
2023-01-13 16:43:26 +00:00
|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
enos = {
|
|
|
|
source = "app.terraform.io/hashicorp-qti/enos"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "vault_cluster_addr_port" {
|
|
|
|
description = "The Raft cluster address port"
|
|
|
|
type = string
|
|
|
|
default = "8201"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "vault_install_dir" {
|
|
|
|
type = string
|
|
|
|
description = "The directory where the Vault binary will be installed"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "primary_leader_public_ip" {
|
|
|
|
type = string
|
|
|
|
description = "Vault primary cluster leader Public IP address"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "primary_leader_private_ip" {
|
|
|
|
type = string
|
|
|
|
description = "Vault primary cluster leader Private IP address"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "secondary_leader_public_ip" {
|
|
|
|
type = string
|
|
|
|
description = "Vault secondary cluster leader Public IP address"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "secondary_leader_private_ip" {
|
|
|
|
type = string
|
|
|
|
description = "Vault secondary cluster leader Private IP address"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "wrapping_token" {
|
|
|
|
type = string
|
|
|
|
description = "The wrapping token created on primary cluster"
|
|
|
|
default = null
|
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
2023-05-12 20:06:46 +00:00
|
|
|
primary_replication_status = jsondecode(enos_remote_exec.verify_replication_status_on_primary.stdout)
|
|
|
|
secondary_replication_status = jsondecode(enos_remote_exec.verify_replication_status_on_secondary.stdout)
|
2023-01-13 16:43:26 +00:00
|
|
|
}
|
|
|
|
|
2023-05-12 20:06:46 +00:00
|
|
|
resource "enos_remote_exec" "verify_replication_status_on_primary" {
|
2023-01-13 16:43:26 +00:00
|
|
|
environment = {
|
2023-05-12 20:06:46 +00:00
|
|
|
VAULT_ADDR = "http://127.0.0.1:8200"
|
|
|
|
VAULT_INSTALL_DIR = var.vault_install_dir
|
|
|
|
PRIMARY_LEADER_PRIV_IP = var.primary_leader_private_ip
|
|
|
|
SECONDARY_LEADER_PRIV_IP = var.secondary_leader_private_ip
|
2023-01-13 16:43:26 +00:00
|
|
|
}
|
|
|
|
|
2023-06-05 15:46:59 +00:00
|
|
|
scripts = [abspath("${path.module}/scripts/verify-replication-status.sh")]
|
2023-01-13 16:43:26 +00:00
|
|
|
|
|
|
|
transport = {
|
|
|
|
ssh = {
|
|
|
|
host = var.primary_leader_public_ip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-12 20:06:46 +00:00
|
|
|
resource "enos_remote_exec" "verify_replication_status_on_secondary" {
|
2023-01-13 16:43:26 +00:00
|
|
|
environment = {
|
2023-05-12 20:06:46 +00:00
|
|
|
VAULT_ADDR = "http://127.0.0.1:8200"
|
|
|
|
VAULT_INSTALL_DIR = var.vault_install_dir
|
|
|
|
PRIMARY_LEADER_PRIV_IP = var.primary_leader_private_ip
|
|
|
|
SECONDARY_LEADER_PRIV_IP = var.secondary_leader_private_ip
|
2023-01-13 16:43:26 +00:00
|
|
|
}
|
|
|
|
|
2023-06-05 15:46:59 +00:00
|
|
|
scripts = [abspath("${path.module}/scripts/verify-replication-status.sh")]
|
2023-01-13 16:43:26 +00:00
|
|
|
|
|
|
|
transport = {
|
|
|
|
ssh = {
|
|
|
|
host = var.secondary_leader_public_ip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-12 20:06:46 +00:00
|
|
|
output "primary_replication_status" {
|
|
|
|
value = local.primary_replication_status
|
|
|
|
}
|
|
|
|
|
2023-01-13 16:43:26 +00:00
|
|
|
output "known_primary_cluster_addrs" {
|
|
|
|
value = local.secondary_replication_status.data.known_primary_cluster_addrs
|
|
|
|
}
|
|
|
|
|
|
|
|
output "secondary_replication_status" {
|
|
|
|
value = local.secondary_replication_status
|
|
|
|
}
|
|
|
|
|
|
|
|
output "primary_replication_data_secondaries" {
|
|
|
|
value = local.primary_replication_status.data.secondaries
|
|
|
|
}
|
|
|
|
|
|
|
|
output "secondary_replication_data_primaries" {
|
|
|
|
value = local.secondary_replication_status.data.primaries
|
|
|
|
}
|