Skip to content

Commit

Permalink
backport of commit dbe41c4 (hashicorp#21006)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Baum <mike.baum@hashicorp.com>
  • Loading branch information
hc-github-team-secure-vault-core and Mike Baum committed Jun 6, 2023
1 parent 71433b9 commit 375bdba
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions enos/modules/vault_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,31 +217,6 @@ resource "enos_vault_start" "followers" {
}
}

# We need to ensure that the directory used for audit logs is present and accessible to the vault
# user on all nodes, since logging will only happen on the leader.
resource "enos_remote_exec" "create_audit_log_dir" {
depends_on = [
enos_vault_start.followers,
]
for_each = toset([
for idx, host in toset(local.instances) : idx
if local.enable_audit_device
])

environment = {
LOG_FILE_PATH = local.audit_device_file_path
SERVICE_USER = local.vault_service_user
}

scripts = [abspath("${path.module}/scripts/create_audit_log_dir.sh")]

transport = {
ssh = {
host = var.target_hosts[each.value].public_ip
}
}
}

resource "enos_vault_init" "leader" {
depends_on = [
enos_vault_start.followers,
Expand Down Expand Up @@ -286,8 +261,34 @@ resource "enos_vault_unseal" "leader" {
}
}

# We need to ensure that the directory used for audit logs is present and accessible to the vault
# user on all nodes, since logging will only happen on the leader.
resource "enos_remote_exec" "create_audit_log_dir" {
depends_on = [
enos_vault_unseal.leader,
]
for_each = toset([
for idx, host in toset(local.instances) : idx
if var.enable_file_audit_device
])

environment = {
LOG_FILE_PATH = local.audit_device_file_path
SERVICE_USER = local.vault_service_user
}

scripts = [abspath("${path.module}/scripts/create_audit_log_dir.sh")]

transport = {
ssh = {
host = var.target_hosts[each.value].public_ip
}
}
}

resource "enos_remote_exec" "enable_file_audit_device" {
depends_on = [
enos_remote_exec.create_audit_log_dir,
enos_vault_unseal.leader,
]
for_each = toset([
Expand Down

0 comments on commit 375bdba

Please sign in to comment.