test: wait for nc to be listening before enabling auditor (#23142) (#23151)

Rather than assuming a short sleep will work, we instead wait until netcat is listening of the socket. We've also configured the netcat listener to persist after the first connection, which allows Vault and us to check the connection without the process closing.

As we implemented this we also ran into AWS issues in us-east-1 and us-west-2, so we've changed our deploy regions until those issues are resolved.

Signed-off-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
Ryan Cragun
2023-09-18 15:10:12 -06:00
committed by GitHub
parent 869c5bf491
commit db1c24d904
131 changed files with 511 additions and 127 deletions

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
regions: regions:
- eu-north-1 - eu-north-1
- ap-south-1 - ap-south-1

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
aws = { aws = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "keys" { output "keys" {
value = { value = {
"us-east-1" = { "us-east-1" = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "aws_ssh_public_key" { variable "aws_ssh_public_key" {
description = "The public key to use for the ssh key" description = "The public key to use for the ssh key"
type = string type = string

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
aws = { aws = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "ci_role" { output "ci_role" {
value = { value = {
name = aws_iam_role.role.name name = aws_iam_role.role.name

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
provider "aws" { provider "aws" {
region = "us-east-1" region = "us-east-1"
alias = "us_east_1" alias = "us_east_1"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
locals { locals {
// This is the code of the service quota to request a change for. Each adjustable limit has a // This is the code of the service quota to request a change for. Each adjustable limit has a
// unique code. See, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicequotas_service_quota#quota_code // unique code. See, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicequotas_service_quota#quota_code
@@ -6,35 +9,35 @@ locals {
} }
resource "aws_servicequotas_service_quota" "vpcs_per_region_us_east_1" { resource "aws_servicequotas_service_quota" "vpcs_per_region_us_east_1" {
provider = aws.us_east_2 provider = aws.us_east_1
quota_code = local.subnets_per_vpcs_quota quota_code = local.subnets_per_vpcs_quota
service_code = "vpc" service_code = "vpc"
value = 50 value = 100
} }
resource "aws_servicequotas_service_quota" "vpcs_per_region_us_east_2" { resource "aws_servicequotas_service_quota" "vpcs_per_region_us_east_2" {
provider = aws.us_east_2 provider = aws.us_east_2
quota_code = local.subnets_per_vpcs_quota quota_code = local.subnets_per_vpcs_quota
service_code = "vpc" service_code = "vpc"
value = 50 value = 100
} }
resource "aws_servicequotas_service_quota" "vpcs_per_region_us_west_1" { resource "aws_servicequotas_service_quota" "vpcs_per_region_us_west_1" {
provider = aws.us_west_1 provider = aws.us_west_1
quota_code = local.subnets_per_vpcs_quota quota_code = local.subnets_per_vpcs_quota
service_code = "vpc" service_code = "vpc"
value = 50 value = 100
} }
resource "aws_servicequotas_service_quota" "vpcs_per_region_us_west_2" { resource "aws_servicequotas_service_quota" "vpcs_per_region_us_west_2" {
provider = aws.us_west_2 provider = aws.us_west_2
quota_code = local.subnets_per_vpcs_quota quota_code = local.subnets_per_vpcs_quota
service_code = "vpc" service_code = "vpc"
value = 50 value = 100
} }
resource "aws_servicequotas_service_quota" "spot_requests_per_region_us_east_1" { resource "aws_servicequotas_service_quota" "spot_requests_per_region_us_east_1" {
provider = aws.us_east_2 provider = aws.us_east_1
quota_code = local.standard_spot_instance_requests_quota quota_code = local.standard_spot_instance_requests_quota
service_code = "ec2" service_code = "ec2"
value = 640 value = 640

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "repository" { variable "repository" {
description = "The GitHub repository, either vault or vault-enterprise" description = "The GitHub repository, either vault or vault-enterprise"
type = string type = string

View File

@@ -15,8 +15,14 @@ globals {
"ubuntu" = var.ubuntu_distro_version "ubuntu" = var.ubuntu_distro_version
} }
packages = ["jq"] packages = ["jq"]
distro_packages = {
ubuntu = ["netcat"]
rhel = ["nc"]
}
sample_attributes = { sample_attributes = {
aws_region = ["us-east-1", "us-west-2"] # aws_region = ["us-east-1", "us-west-2"]
# NOTE(9/18/23): use more expensive regions temporarily until AWS network outage is resolved.
aws_region = ["us-east-2", "us-west-1"]
} }
tags = merge({ tags = merge({
"Project Name" : var.project_name "Project Name" : var.project_name

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
module "autopilot_upgrade_storageconfig" { module "autopilot_upgrade_storageconfig" {
source = "./modules/autopilot_upgrade_storageconfig" source = "./modules/autopilot_upgrade_storageconfig"
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
provider "aws" "default" { provider "aws" "default" {
region = var.aws_region region = var.aws_region
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "agent" { scenario "agent" {
matrix { matrix {
arch = ["amd64", "arm64"] arch = ["amd64", "arm64"]
@@ -106,17 +109,17 @@ scenario "agent" {
} }
variables { variables {
artifactory_release = matrix.artifact_source == "artifactory" ? step.build_vault.vault_artifactory_release : null artifactory_release = matrix.artifact_source == "artifactory" ? step.build_vault.vault_artifactory_release : null
awskms_unseal_key_arn = step.create_vpc.kms_key_arn awskms_unseal_key_arn = step.create_vpc.kms_key_arn
cluster_name = step.create_vault_cluster_targets.cluster_name cluster_name = step.create_vault_cluster_targets.cluster_name
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = var.vault_install_dir install_dir = var.vault_install_dir
license = matrix.edition != "oss" ? step.read_license.license : null license = matrix.edition != "oss" ? step.read_license.license : null
local_artifact_path = local.bundle_path local_artifact_path = local.bundle_path
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
storage_backend = "raft" storage_backend = "raft"
target_hosts = step.create_vault_cluster_targets.hosts target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = "shamir" unseal_method = "shamir"
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "autopilot" { scenario "autopilot" {
matrix { matrix {
arch = ["amd64", "arm64"] arch = ["amd64", "arm64"]
@@ -112,15 +115,15 @@ scenario "autopilot" {
cluster_name = step.create_vault_cluster_targets.cluster_name cluster_name = step.create_vault_cluster_targets.cluster_name
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_license.license : null license = matrix.edition != "oss" ? step.read_license.license : null
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
release = var.vault_autopilot_initial_release release = var.vault_autopilot_initial_release
storage_backend = "raft" storage_backend = "raft"
storage_backend_addl_config = { storage_backend_addl_config = {
autopilot_upgrade_version = var.vault_autopilot_initial_release.version autopilot_upgrade_version = var.vault_autopilot_initial_release.version
} }
target_hosts = step.create_vault_cluster_targets.hosts target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = matrix.seal unseal_method = matrix.seal
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
} }
} }
@@ -213,7 +216,7 @@ scenario "autopilot" {
license = matrix.edition != "oss" ? step.read_license.license : null license = matrix.edition != "oss" ? step.read_license.license : null
local_artifact_path = local.artifact_path local_artifact_path = local.artifact_path
manage_service = local.manage_service manage_service = local.manage_service
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
root_token = step.create_vault_cluster.root_token root_token = step.create_vault_cluster.root_token
shamir_unseal_keys = matrix.seal == "shamir" ? step.create_vault_cluster.unseal_keys_hex : null shamir_unseal_keys = matrix.seal == "shamir" ? step.create_vault_cluster.unseal_keys_hex : null
storage_backend = "raft" storage_backend = "raft"
@@ -221,7 +224,7 @@ scenario "autopilot" {
storage_node_prefix = "upgrade_node" storage_node_prefix = "upgrade_node"
target_hosts = step.create_vault_cluster_upgrade_targets.hosts target_hosts = step.create_vault_cluster_upgrade_targets.hosts
unseal_method = matrix.seal unseal_method = matrix.seal
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
} }
} }

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
scenario "proxy" { scenario "proxy" {
matrix { matrix {
@@ -101,17 +101,17 @@ scenario "proxy" {
} }
variables { variables {
artifactory_release = matrix.artifact_source == "artifactory" ? step.build_vault.vault_artifactory_release : null artifactory_release = matrix.artifact_source == "artifactory" ? step.build_vault.vault_artifactory_release : null
awskms_unseal_key_arn = step.create_vpc.kms_key_arn awskms_unseal_key_arn = step.create_vpc.kms_key_arn
cluster_name = step.create_vault_cluster_targets.cluster_name cluster_name = step.create_vault_cluster_targets.cluster_name
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = var.vault_install_dir install_dir = var.vault_install_dir
license = matrix.edition != "oss" ? step.read_license.license : null license = matrix.edition != "oss" ? step.read_license.license : null
local_artifact_path = local.bundle_path local_artifact_path = local.bundle_path
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
storage_backend = "raft" storage_backend = "raft"
target_hosts = step.create_vault_cluster_targets.hosts target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = "shamir" unseal_method = "shamir"
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
// The replication scenario configures performance replication between two Vault clusters and verifies // The replication scenario configures performance replication between two Vault clusters and verifies
// known_primary_cluster_addrs are updated on secondary Vault cluster with the IP addresses of replaced // known_primary_cluster_addrs are updated on secondary Vault cluster with the IP addresses of replaced
// nodes on primary Vault cluster // nodes on primary Vault cluster
@@ -236,15 +239,15 @@ scenario "replication" {
edition = var.backend_edition edition = var.backend_edition
version = matrix.consul_version version = matrix.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
local_artifact_path = local.artifact_path local_artifact_path = local.artifact_path
manage_service = local.manage_service manage_service = local.manage_service
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
storage_backend = matrix.primary_backend storage_backend = matrix.primary_backend
target_hosts = step.create_primary_cluster_targets.hosts target_hosts = step.create_primary_cluster_targets.hosts
unseal_method = matrix.primary_seal unseal_method = matrix.primary_seal
} }
} }
@@ -293,15 +296,15 @@ scenario "replication" {
edition = var.backend_edition edition = var.backend_edition
version = matrix.consul_version version = matrix.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
local_artifact_path = local.artifact_path local_artifact_path = local.artifact_path
manage_service = local.manage_service manage_service = local.manage_service
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
storage_backend = matrix.secondary_backend storage_backend = matrix.secondary_backend
target_hosts = step.create_secondary_cluster_targets.hosts target_hosts = step.create_secondary_cluster_targets.hosts
unseal_method = matrix.secondary_seal unseal_method = matrix.secondary_seal
} }
} }
@@ -535,20 +538,20 @@ scenario "replication" {
edition = var.backend_edition edition = var.backend_edition
version = matrix.consul_version version = matrix.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
force_unseal = matrix.primary_seal == "shamir" force_unseal = matrix.primary_seal == "shamir"
initialize_cluster = false initialize_cluster = false
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
local_artifact_path = local.artifact_path local_artifact_path = local.artifact_path
manage_service = local.manage_service manage_service = local.manage_service
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
root_token = step.create_primary_cluster.root_token root_token = step.create_primary_cluster.root_token
shamir_unseal_keys = matrix.primary_seal == "shamir" ? step.create_primary_cluster.unseal_keys_hex : null shamir_unseal_keys = matrix.primary_seal == "shamir" ? step.create_primary_cluster.unseal_keys_hex : null
storage_backend = matrix.primary_backend storage_backend = matrix.primary_backend
storage_node_prefix = "newprimary_node" storage_node_prefix = "newprimary_node"
target_hosts = step.create_primary_cluster_additional_targets.hosts target_hosts = step.create_primary_cluster_additional_targets.hosts
unseal_method = matrix.primary_seal unseal_method = matrix.primary_seal
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "smoke" { scenario "smoke" {
matrix { matrix {
arch = ["amd64", "arm64"] arch = ["amd64", "arm64"]
@@ -177,15 +180,15 @@ scenario "smoke" {
edition = var.backend_edition edition = var.backend_edition
version = matrix.consul_version version = matrix.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
local_artifact_path = local.artifact_path local_artifact_path = local.artifact_path
manage_service = local.manage_service manage_service = local.manage_service
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
storage_backend = matrix.backend storage_backend = matrix.backend
target_hosts = step.create_vault_cluster_targets.hosts target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = matrix.seal unseal_method = matrix.seal
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "ui" { scenario "ui" {
matrix { matrix {
edition = ["oss", "ent"] edition = ["oss", "ent"]
@@ -163,13 +166,14 @@ scenario "ui" {
edition = var.backend_edition edition = var.backend_edition
version = local.consul_version version = local.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
local_artifact_path = local.bundle_path local_artifact_path = local.bundle_path
storage_backend = matrix.backend packages = global.distro_packages["ubuntu"]
target_hosts = step.create_vault_cluster_targets.hosts storage_backend = matrix.backend
unseal_method = local.seal target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = local.seal
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "upgrade" { scenario "upgrade" {
matrix { matrix {
arch = ["amd64", "arm64"] arch = ["amd64", "arm64"]
@@ -177,14 +180,14 @@ scenario "upgrade" {
edition = var.backend_edition edition = var.backend_edition
version = matrix.consul_version version = matrix.consul_version
} : null } : null
enable_file_audit_device = var.vault_enable_file_audit_device enable_audit_devices = var.vault_enable_audit_devices
install_dir = local.vault_install_dir install_dir = local.vault_install_dir
license = matrix.edition != "oss" ? step.read_vault_license.license : null license = matrix.edition != "oss" ? step.read_vault_license.license : null
packages = global.packages packages = concat(global.packages, global.distro_packages[matrix.distro])
release = var.vault_upgrade_initial_release release = var.vault_upgrade_initial_release
storage_backend = matrix.backend storage_backend = matrix.backend
target_hosts = step.create_vault_cluster_targets.hosts target_hosts = step.create_vault_cluster_targets.hosts
unseal_method = matrix.seal unseal_method = matrix.seal
} }
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform_cli "default" { terraform_cli "default" {
plugin_cache_dir = var.terraform_plugin_cache_dir != null ? abspath(var.terraform_plugin_cache_dir) : null plugin_cache_dir = var.terraform_plugin_cache_dir != null ? abspath(var.terraform_plugin_cache_dir) : null

View File

@@ -1,11 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
variable "artifact_path" {
type = string
description = "The local path for dev artifact to test"
default = null
}
variable "artifactory_username" { variable "artifactory_username" {
type = string type = string
@@ -148,8 +142,8 @@ variable "vault_build_date" {
default = "" default = ""
} }
variable "vault_enable_file_audit_device" { variable "vault_enable_audit_devices" {
description = "If true the file audit device will be enabled at the path /var/log/vault_audit.log" description = "If true every audit device will be enabled"
type = bool type = bool
default = true default = true
} }

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
# artifactory_username is the username to use when testing an artifact stored in artfactory. # artifactory_username is the username to use when testing an artifact stored in artfactory.
# artifactory_username = "yourname@hashicorp.com" # artifactory_username = "yourname@hashicorp.com"
@@ -87,9 +87,12 @@
# date to match" # date to match"
# vault_build_date = "2023-07-07T14:06:37Z" // make ci-get-date for example # vault_build_date = "2023-07-07T14:06:37Z" // make ci-get-date for example
# vault_enable_file_audit_device sets whether or not to enable the 'file' audit device. It true it # vault_enable_audit_devices sets whether or not to enable every audit device. It true
# will be enabled at the path /var/log/vault_audit.log # a file audit device will be enabled at the path /var/log/vault_audit.log, the syslog
# vault_enable_file_audit_device = true # audit device will be enabled, and a socket audit device connecting to 127.0.0.1:9090
# will be enabled. The netcat program is run in listening mode to provide an endpoint
# that the socket audit device can connect to.
# vault_enable_audit_devices = true
# vault_install_dir is the directory where the vault binary will be installed on # vault_install_dir is the directory where the vault binary will be installed on
# the remote machines. # the remote machines.

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
module "create_kind_cluster" { module "create_kind_cluster" {
source = "../modules/local_kind_cluster" source = "../modules/local_kind_cluster"
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
provider "enos" "default" {} provider "enos" "default" {}
provider "helm" "default" { provider "helm" "default" {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
scenario "k8s" { scenario "k8s" {
matrix { matrix {
edition = ["oss", "ent"] edition = ["oss", "ent"]

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform "k8s" { terraform "k8s" {
required_version = ">= 1.2.0" required_version = ">= 1.2.0"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_image_repository" { variable "vault_image_repository" {
description = "The repository for the docker image to load, i.e. hashicorp/vault" description = "The repository for the docker image to load, i.e. hashicorp/vault"
type = string type = string

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_product_version" {} variable "vault_product_version" {}
output "storage_addl_config" { output "storage_addl_config" {

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_version = ">= 1.2.0" required_version = ">= 1.2.0"

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
output "private_ips" { output "private_ips" {
description = "Consul cluster target host private_ips" description = "Consul cluster target host private_ips"

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
variable "cluster_name" { variable "cluster_name" {
type = string type = string

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
// Shim module to handle the fact that Vault doesn't actually need a backend module when we use raft. // Shim module to handle the fact that Vault doesn't actually need a backend module when we use raft.
terraform { terraform {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
# Shim module since CRT provided things will use the crt_bundle_path variable # Shim module since CRT provided things will use the crt_bundle_path variable
variable "bundle_path" { variable "bundle_path" {
default = "/tmp/vault.zip" default = "/tmp/vault.zip"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -eux -o pipefail set -eux -o pipefail
# Install yarn so we can build the UI # Install yarn so we can build the UI

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
data "aws_availability_zones" "available" { data "aws_availability_zones" "available" {
state = "available" state = "available"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "vpc_id" { output "vpc_id" {
description = "Created VPC ID" description = "Created VPC ID"
value = aws_vpc.vpc.id value = aws_vpc.vpc.id

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "name" { variable "name" {
type = string type = string
default = "vault-ci" default = "vault-ci"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
locals { locals {
architectures = toset(["arm64", "x86_64"]) architectures = toset(["arm64", "x86_64"])
canonical_owner_id = "099720109477" canonical_owner_id = "099720109477"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,4 +1,7 @@
#!/bin/env bash #!/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -eu -o pipefail set -eu -o pipefail
pushd "$(git rev-parse --show-toplevel)" > /dev/null pushd "$(git rev-parse --show-toplevel)" > /dev/null

View File

@@ -1,10 +1,9 @@
#!/bin/env bash #!/bin/env bash
set -eu -o pipefail
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1 # SPDX-License-Identifier: BUSL-1.1
set -euo pipefail
# Get the full version information # Get the full version information
# this is only needed for local enos builds in order to get the default version from version_base.go # this is only needed for local enos builds in order to get the default version from version_base.go
# this should match the default version that the binary has been built with # this should match the default version that the binary has been built with

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_version = ">= 1.0" required_version = ">= 1.0"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "context_name" { variable "context_name" {
type = string type = string
description = "The name of the k8s context for Vault" description = "The name of the k8s context for Vault"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_instance_count" { variable "vault_instance_count" {
type = number type = number
description = "How many vault instances are in the cluster" description = "How many vault instances are in the cluster"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
# The Vault replication smoke test, documented in # The Vault replication smoke test, documented in
# https://docs.google.com/document/d/16sjIk3hzFDPyY5A9ncxTZV_9gnpYSF1_Vx6UA1iiwgI/edit#heading=h.kgrxf0f1et25 # https://docs.google.com/document/d/16sjIk3hzFDPyY5A9ncxTZV_9gnpYSF1_Vx6UA1iiwgI/edit#heading=h.kgrxf0f1et25

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_instance_count" { variable "vault_instance_count" {
type = number type = number
description = "How many vault instances are in the cluster" description = "How many vault instances are in the cluster"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_instance_count" { variable "vault_instance_count" {
type = number type = number
description = "How many vault instances are in the cluster" description = "How many vault instances are in the cluster"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
# The Vault smoke test to verify the Vault version installed # The Vault smoke test to verify the Vault version installed

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_instance_count" { variable "vault_instance_count" {
type = number type = number
description = "How many vault instances are in the cluster" description = "How many vault instances are in the cluster"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_instance_count" { variable "vault_instance_count" {
type = number type = number
description = "How many vault instances are in the cluster" description = "How many vault instances are in the cluster"

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "file_name" {} variable "file_name" {}
output "license" { output "license" {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
# We need to specify the provider source in each module until we publish it # We need to specify the provider source in each module until we publish it

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "cluster_name" { output "cluster_name" {
value = local.cluster_name value = local.cluster_name
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "ami_id" { variable "ami_id" {
description = "The machine image identifier" description = "The machine image identifier"
type = string type = string

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
# We need to specify the provider source in each module until we publish it # We need to specify the provider source in each module until we publish it

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "cluster_name" { output "cluster_name" {
value = local.cluster_name value = local.cluster_name
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "ami_id" { variable "ami_id" {
description = "The machine image identifier" description = "The machine image identifier"
type = string type = string

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
# We need to specify the provider source in each module until we publish it # We need to specify the provider source in each module until we publish it

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
# We need to specify the provider source in each module until we publish it # We need to specify the provider source in each module until we publish it

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "cluster_name" { output "cluster_name" {
value = local.cluster_name value = local.cluster_name
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "ami_id" { variable "ami_id" {
description = "The machine image identifier" description = "The machine image identifier"
type = string type = string

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
aws = { aws = {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
locals { locals {
// file name extensions for the install packages of vault for the various architectures, distributions and editions // file name extensions for the install packages of vault for the various architectures, distributions and editions

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "url" { output "url" {
value = data.enos_artifactory_item.vault.results[0].url value = data.enos_artifactory_item.vault.results[0].url

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
# We need to specify the provider source in each module until we publish it # We need to specify the provider source in each module until we publish it
@@ -15,7 +18,7 @@ locals {
audit_device_file_path = "/var/log/vault/vault_audit.log" audit_device_file_path = "/var/log/vault/vault_audit.log"
bin_path = "${var.install_dir}/vault" bin_path = "${var.install_dir}/vault"
consul_bin_path = "${var.consul_install_dir}/consul" consul_bin_path = "${var.consul_install_dir}/consul"
enable_audit_device = var.enable_file_audit_device && var.initialize_cluster enable_audit_devices = var.enable_audit_devices && var.initialize_cluster
// In order to get Terraform to plan we have to use collections with keys // In order to get Terraform to plan we have to use collections with keys
// that are known at plan time. In order for our module to work our var.target_hosts // that are known at plan time. In order for our module to work our var.target_hosts
// must be a map with known keys at plan time. Here we're creating locals // must be a map with known keys at plan time. Here we're creating locals
@@ -277,7 +280,7 @@ resource "enos_remote_exec" "create_audit_log_dir" {
] ]
for_each = toset([ for_each = toset([
for idx, host in toset(local.instances) : idx for idx, host in toset(local.instances) : idx
if var.enable_file_audit_device if var.enable_audit_devices
]) ])
environment = { environment = {
@@ -294,14 +297,14 @@ resource "enos_remote_exec" "create_audit_log_dir" {
} }
} }
resource "enos_remote_exec" "enable_file_audit_device" { resource "enos_remote_exec" "enable_audit_devices" {
depends_on = [ depends_on = [
enos_remote_exec.create_audit_log_dir, enos_remote_exec.create_audit_log_dir,
enos_vault_unseal.leader, enos_vault_unseal.leader,
] ]
for_each = toset([ for_each = toset([
for idx in local.leader : idx for idx in local.leader : idx
if local.enable_audit_device if local.enable_audit_devices
]) ])
environment = { environment = {

View File

@@ -1,6 +1,9 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "audit_device_file_path" { output "audit_device_file_path" {
description = "The file path for the audit device, if enabled" description = "The file path for the audit device, if enabled"
value = var.enable_file_audit_device ? local.audit_device_file_path : "file audit device not enabled" value = var.enable_audit_devices ? local.audit_device_file_path : "file audit device not enabled"
} }
output "cluster_name" { output "cluster_name" {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -eux set -eux

View File

@@ -1,5 +1,35 @@
#!/bin/env sh #!/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -eux set -exo pipefail
# Run nc to listen on port 9090 for the socket auditor. We spawn nc
# with nohup to ensure that the listener doesn't expect a SIGHUP and
# thus block the SSH session from exiting or terminating on exit.
# We immediately write to STDIN from /dev/null to give nc an
# immediate EOF so as to not block on expecting STDIN.
nohup nc -kl 9090 &> /dev/null < /dev/null &
# Wait for nc to be listening before we attempt to enable the socket auditor.
retries=3
count=0
until nc -zv 127.0.0.1 9090 &> /dev/null < /dev/null; do
wait=$((2 ** count))
count=$((count + 1))
if [ "$count" -lt "$retries" ]; then
sleep "$wait"
else
echo "Timed out waiting for nc to listen on 127.0.0.1:9090" 1>&2
exit 1
fi
done
sleep 1
# Enable the auditors.
$VAULT_BIN_PATH audit enable file file_path="$LOG_FILE_PATH" $VAULT_BIN_PATH audit enable file file_path="$LOG_FILE_PATH"
$VAULT_BIN_PATH audit enable syslog tag="vault" facility="AUTH"
$VAULT_BIN_PATH audit enable socket address="127.0.0.1:9090" || true

View File

@@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -ex -o pipefail set -ex -o pipefail
@@ -38,8 +41,8 @@ if [ -f /etc/debian_version ]; then
cd /tmp cd /tmp
retry 5 sudo apt update retry 5 sudo apt update
retry 5 sudo apt install -y "$${packages[@]}" retry 5 sudo apt install -y $${packages[@]}
else else
cd /tmp cd /tmp
retry 7 sudo yum -y install "$${packages[@]}" retry 7 sudo yum -y install $${packages[@]}
fi fi

View File

@@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
license='${license}' license='${license}'
if test $license = "none"; then if test $license = "none"; then

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "artifactory_release" { variable "artifactory_release" {
type = object({ type = object({
username = string username = string
@@ -93,8 +96,8 @@ variable "consul_release" {
} }
} }
variable "enable_file_audit_device" { variable "enable_audit_devices" {
description = "If true the file audit device will be enabled at the path /var/log/vault_audit.log" description = "If true every audit device will be enabled"
type = bool type = bool
default = true default = true
} }

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,5 +1,5 @@
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc. # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e set -e

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
terraform { terraform {
required_providers { required_providers {
enos = { enos = {

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
output "ui_test_stderr" { output "ui_test_stderr" {
value = var.ui_run_tests ? enos_local_exec.test_ui[0].stderr : "No std out tests where not run" value = var.ui_run_tests ? enos_local_exec.test_ui[0].stderr : "No std out tests where not run"
} }

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -eux -o pipefail set -eux -o pipefail

View File

@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
variable "vault_addr" { variable "vault_addr" {
description = "The host address for the vault instance to test" description = "The host address for the vault instance to test"
type = string type = string

Some files were not shown because too many files have changed in this diff Show More