parameterize CA script

This commit is contained in:
Pim Kunis 2023-04-24 00:05:48 +02:00
parent dee050c05a
commit 71870c1fda
3 changed files with 8 additions and 2 deletions

View file

@ -2,11 +2,11 @@
set -euo pipefail
IFS=$'\n\t'
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost)"')"
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost) CASCRIPT=\.(.cascript)"')"
# TODO: Can this be done more eye-pleasingly?
set +e
CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '/root/ca.sh host "'"$PUBKEY"'" "'"$HOST"'".dmz')
CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '"'"$CASCRIPT"'" host "'"$PUBKEY"'" "'"$HOST"'".dmz')
retval=$?
set -e

View file

@ -38,6 +38,7 @@ data "external" "cert" {
pubkey = trimspace(data.tls_public_key.debian.public_key_openssh)
host = var.name
cahost = var.ca_host
cascript = var.ca_script
}
}

View file

@ -37,6 +37,11 @@ variable "ca_host" {
description = "Host to contact when fetching a SSH host certificate."
}
variable "ca_script" {
type = string
description = "Script to call when fetching a SSH host certificate."
}
variable "domain_name" {
type = string
default = null