support multiple SSH CA key pairs
This commit is contained in:
parent
9866130719
commit
9c1aa00775
3 changed files with 33 additions and 26 deletions
|
@ -2,11 +2,11 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost) CASCRIPT=\(.cascript)"')"
|
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost) CASCRIPT=\(.cascript) CAKEY=\(.cakey)"')"
|
||||||
|
|
||||||
# TODO: Can this be done more eye-pleasingly?
|
# TODO: Can this be done more eye-pleasingly?
|
||||||
set +e
|
set +e
|
||||||
CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '"'"$CASCRIPT"'" host "'"$PUBKEY"'" "'"$HOST"'".dmz')
|
CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '"'"$CASCRIPT"'" "'"$CAKEY"'" host "'"$PUBKEY"'" "'"$HOST"'".dmz')
|
||||||
retval=$?
|
retval=$?
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
1
main.tf
1
main.tf
|
@ -39,6 +39,7 @@ data "external" "cert" {
|
||||||
host = var.name
|
host = var.name
|
||||||
cahost = var.ca_host
|
cahost = var.ca_host
|
||||||
cascript = var.ca_script
|
cascript = var.ca_script
|
||||||
|
cakey = var.ca_key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@ variable "ca_script" {
|
||||||
description = "Script to call when fetching a SSH host certificate."
|
description = "Script to call when fetching a SSH host certificate."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "ca_key" {
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
description = "File name of the SSH CA key pair."
|
||||||
|
}
|
||||||
|
|
||||||
variable "domain_name" {
|
variable "domain_name" {
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
|
|
Reference in a new issue