From efe53f3d5595c76681aaf02ee102d53d1546c626 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 1 Apr 2016 11:24:09 +0200 Subject: [PATCH] Add setup scripts to install/run vault locally and using docker compose --- docker-compose.yml | 8 ++++++ src/test/bash/env.sh | 9 +++++++ src/test/bash/install_vault.sh | 45 ++++++++++++++++++++++++++++++++ src/test/bash/local_run_vault.sh | 9 +++++++ src/test/resources/vault.conf | 6 +++-- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml create mode 100755 src/test/bash/env.sh create mode 100755 src/test/bash/install_vault.sh create mode 100755 src/test/bash/local_run_vault.sh diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..39f5469c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +# Work in Progress +vault: + image: cgswong/vault + volumes: + - ./src/test/resources:/config + ports: + - "8200:8200" + command: server -config /config/vault.conf diff --git a/src/test/bash/env.sh b/src/test/bash/env.sh new file mode 100755 index 00000000..1cf1fb9a --- /dev/null +++ b/src/test/bash/env.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +########################################################################### +# Vault environment settings. Source this file. # +########################################################################### + +export VAULT_TOKEN=00000000-0000-0000-0000-000000000000 +export VAULT_ADDR=http://localhost:8200 +export VAULT_SKIP_VERIFY=true diff --git a/src/test/bash/install_vault.sh b/src/test/bash/install_vault.sh new file mode 100755 index 00000000..8eb28e88 --- /dev/null +++ b/src/test/bash/install_vault.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +########################################################################### +# Download and Install Vault # +# This script is prepared for caching of the vault/download directory # +########################################################################### + + +VAULT_VER="0.5.2" +UNAME=$(uname -s | tr '[:upper:]' '[:lower:]') +VAULT_ZIP="vault_${VAULT_VER}_${UNAME}_amd64.zip" +IGNORE_CERTS="${IGNORE_CERTS:-no}" + + +# cleanup +mkdir -p vault/download +cd vault + +if [[ ! -f "download/${VAULT_ZIP}" ]] ; then + cd download + # install Vault + if [[ "${IGNORE_CERTS}" == "no" ]] ; then + echo "Downloading consul with certs verification" + wget "https://releases.hashicorp.com/vault/${VAULT_VER}/${VAULT_ZIP}" + else + echo "WARNING... Downloading consul WITHOUT certs verification" + wget "https://releases.hashicorp.com/vault/${VAULT_VER}/${VAULT_ZIP}" --no-check-certificate + fi + + if [[ $? != 0 ]] ; then + echo "Cannot download vault" + exit 1 + fi + cd .. +fi + +if [[ -f vault ]] ; then + rm vault +fi + +unzip download/${VAULT_ZIP} +chmod a+x vault + +# check +./vault --version \ No newline at end of file diff --git a/src/test/bash/local_run_vault.sh b/src/test/bash/local_run_vault.sh new file mode 100755 index 00000000..4d3828b0 --- /dev/null +++ b/src/test/bash/local_run_vault.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +########################################################################### +# Start Vault on localhost:8200 # +########################################################################### + +BASEDIR=`dirname $0`/../../.. +./vault/vault server -config=${BASEDIR}/src/test/resources/vault.conf +exit $? diff --git a/src/test/resources/vault.conf b/src/test/resources/vault.conf index 33be49bc..b30cf3ff 100644 --- a/src/test/resources/vault.conf +++ b/src/test/resources/vault.conf @@ -2,6 +2,8 @@ backend "inmem" { } listener "tcp" { - address = "127.0.0.1:8200" + address = "0.0.0.0:8200" tls_disable = 1 -} \ No newline at end of file +} + +disable_mlock = true