Add support for vault kv v2 api, key off of VAULT_KV_V2 env var

This commit is contained in:
Sean Brandt 2019-07-14 10:33:44 -04:00
parent 5f94474330
commit f446a6c9ec

View File

@ -2,10 +2,10 @@
# Here is a script to deploy cert to hashicorp vault # Here is a script to deploy cert to hashicorp vault
# (https://www.vaultproject.io/) # (https://www.vaultproject.io/)
# #
# it requires the vault binary to be available in PATH, and the following # it requires the vault binary to be available in PATH, and the following
# environment variables: # environment variables:
# #
# VAULT_PREFIX - this contains the prefix path in vault # VAULT_PREFIX - this contains the prefix path in vault
# VAULT_ADDR - vault requires this to find your vault server # VAULT_ADDR - vault requires this to find your vault server
# #
@ -51,6 +51,11 @@ vault_cli_deploy() {
if [ -n "$FABIO" ]; then if [ -n "$FABIO" ]; then
$VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}" cert=@"$_cfullchain" key=@"$_ckey" || return 1 $VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}" cert=@"$_cfullchain" key=@"$_ckey" || return 1
elif [ -n "$VAULT_KV_V2" ]; then
$VAULT_CMD kv put "${VAULT_PREFIX}/${_cdomain}" cert=@"$_ccert" \
key=@"$_ckey" \
chain=@"$_cca" \
fullchain=@"$_cfullchain" || return 1
else else
$VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}/cert.pem" value=@"$_ccert" || return 1 $VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}/cert.pem" value=@"$_ccert" || return 1
$VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}/cert.key" value=@"$_ckey" || return 1 $VAULT_CMD write "${VAULT_PREFIX}/${_cdomain}/cert.key" value=@"$_ckey" || return 1