2018-11-05 20:24:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Generate an OpenAPI document for all backends.
|
|
|
|
#
|
|
|
|
# Assumptions:
|
|
|
|
#
|
|
|
|
# 1. Vault has been checked out at an appropriate version and built
|
|
|
|
# 2. vault executable is in your path
|
2018-11-30 00:08:44 +00:00
|
|
|
# 3. Vault isn't already running
|
2018-11-05 20:24:39 +00:00
|
|
|
|
|
|
|
echo "Starting Vault..."
|
|
|
|
if pgrep -x "vault" > /dev/null
|
|
|
|
then
|
|
|
|
echo "Vault is already running. Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vault server -dev -dev-root-token-id=root &
|
|
|
|
sleep 2
|
|
|
|
VAULT_PID=$!
|
|
|
|
|
|
|
|
echo "Mounting all builtin backends..."
|
|
|
|
|
|
|
|
# auth backends
|
|
|
|
vault auth enable alicloud
|
|
|
|
vault auth enable app-id
|
|
|
|
vault auth enable approle
|
|
|
|
vault auth enable aws
|
|
|
|
vault auth enable azure
|
|
|
|
vault auth enable centrify
|
|
|
|
vault auth enable cert
|
2020-02-01 00:05:39 +00:00
|
|
|
vault auth enable cf
|
2018-11-05 20:24:39 +00:00
|
|
|
vault auth enable gcp
|
|
|
|
vault auth enable github
|
|
|
|
vault auth enable jwt
|
2020-02-01 00:05:39 +00:00
|
|
|
vault auth enable kerberos
|
2018-11-05 20:24:39 +00:00
|
|
|
vault auth enable kubernetes
|
|
|
|
vault auth enable ldap
|
2020-02-01 00:05:39 +00:00
|
|
|
vault auth enable oci
|
|
|
|
vault auth enable oidc
|
2018-11-05 20:24:39 +00:00
|
|
|
vault auth enable okta
|
|
|
|
vault auth enable radius
|
|
|
|
vault auth enable userpass
|
|
|
|
|
|
|
|
# secrets backends
|
|
|
|
vault secrets enable ad
|
|
|
|
vault secrets enable alicloud
|
|
|
|
vault secrets enable aws
|
|
|
|
vault secrets enable azure
|
|
|
|
vault secrets enable cassandra
|
|
|
|
vault secrets enable consul
|
|
|
|
vault secrets enable database
|
|
|
|
vault secrets enable gcp
|
2019-07-25 00:03:03 +00:00
|
|
|
vault secrets enable gcpkms
|
2018-11-05 20:24:39 +00:00
|
|
|
vault secrets enable kv
|
|
|
|
vault secrets enable mongodb
|
2020-02-19 17:39:14 +00:00
|
|
|
vault secrets enable mongodbatlas
|
2018-11-05 20:24:39 +00:00
|
|
|
vault secrets enable mssql
|
|
|
|
vault secrets enable mysql
|
|
|
|
vault secrets enable nomad
|
2020-02-15 18:21:07 +00:00
|
|
|
vault secrets enable openldap
|
2018-11-05 20:24:39 +00:00
|
|
|
vault secrets enable pki
|
|
|
|
vault secrets enable postgresql
|
|
|
|
vault secrets enable rabbitmq
|
|
|
|
vault secrets enable ssh
|
2021-02-19 22:38:56 +00:00
|
|
|
vault secrets enable terraform
|
2018-11-05 20:24:39 +00:00
|
|
|
vault secrets enable totp
|
|
|
|
vault secrets enable transit
|
|
|
|
|
2020-04-15 16:12:12 +00:00
|
|
|
# Enable enterprise features
|
|
|
|
if [[ ! -z "$VAULT_LICENSE" ]]
|
2019-07-25 00:03:03 +00:00
|
|
|
then
|
2020-04-15 16:12:12 +00:00
|
|
|
vault write sys/license text="$VAULT_LICENSE"
|
2019-07-25 00:03:03 +00:00
|
|
|
vault secrets enable kmip
|
2020-04-15 16:12:12 +00:00
|
|
|
vault secrets enable transform
|
2019-07-25 00:03:03 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Output OpenAPI, optionally formatted
|
2019-05-03 22:12:24 +00:00
|
|
|
if [ "$1" == "-p" ]; then
|
|
|
|
curl -H "X-Vault-Token: root" "http://127.0.0.1:8200/v1/sys/internal/specs/openapi" | jq > openapi.json
|
|
|
|
else
|
|
|
|
curl -H "X-Vault-Token: root" "http://127.0.0.1:8200/v1/sys/internal/specs/openapi" > openapi.json
|
|
|
|
fi
|
2018-11-05 20:24:39 +00:00
|
|
|
|
|
|
|
kill $VAULT_PID
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "\nopenapi.json generated."
|