Skip to content

Commit

Permalink
New version
Browse files Browse the repository at this point in the history
- Disable script checks in 0.9.0 configurations
- Spruce up scripts
- Add execute versus source checking to form script (thanks @fprimex)
- Drop to executing form instead of sourcing and prompt user to set env vars
- Add examples directory and initial Vault PKI policy example
- Add CONTRIBUTING.md
- Add CONTRIBUTORS.md
  • Loading branch information
brianshumate committed Jul 24, 2017
1 parent 02b611e commit e879a47
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@
- Remove templates for invalid Consul versions
- Update documentation

## v1.4.4 (UNRELEASED)
## v1.4.4

- Disable script checks in 0.9.0 configurations
- Spruce up scripts
- Add execute versus source checking to form script (thanks @fprimex)
- Drop to executing form instead of sourcing and prompt user to set env vars
- Add examples directory and initial Vault PKI policy example
- Add CONTRIBUTING.md
- Add CONTRIBUTORS.md
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ After doing so, it's just 3 steps to forming your own Vaultron:

1. `git clone https://github.com/brianshumate/vaultron.git`
2. `cd vaultron`
3. `. ./form`
3. `./form`

Note the completion message about setting important environment variables
before executing the `vault` and `consul` CLI commands. You'll want to set
those environment variables in your shell before trying to use the CLI tools
with Vaultron.

### What's Next?

Expand Down Expand Up @@ -167,7 +172,7 @@ variable to override:

```
export TF_VAR_vault_version=0.6.5
. ./form
./form
./blazing_sword
...
Version: 0.6.5
Expand All @@ -179,7 +184,7 @@ the `TF_VAR_consul_version` environment variable as well:

```
export TF_VAR_consul_version=0.7.5
. ./form
./form
consul members
Node Address Status Type Build Protocol DC
consul_oss_client_1 172.17.0.6:8301 alive client 0.7.5 2 arus
Expand Down
29 changes: 10 additions & 19 deletions form
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,29 @@

# shellcheck disable=SC2059

execute_message () {
_form_message () {
cat << 'EOF'
It appears that you have executed the form script; the preferred
method is to source it like '. ./form'. If you execute it, you need
to first manually export the following environment variables as shown:
Now that Vaultron is formed, you can visit the Consul web UI
at http://localhost:8500
Or you can interact with the Vault and Consul at the command line level by
first setting the following environment variables as shown:
export CONSUL_HTTP_ADDR="localhost:8500"
export VAULT_ADDR="http://localhost:8200"
Then you can use the vault and consul commands as needed.
EOF
}

if ! awk -v name="form" -v p=$0 'BEGIN{
exit substr(p, length(p)-length(name)+1, length(name)) == name
}'; then
# This script was run instead of sourced, which is fine if required
# variables are set correctly.
if [ "localhost:8500" != "$CONSUL_HTTP_ADDR" -a \
"http://localhost:8200" != "$VAULT_ADDR" ]; then
execute_message
exit 1
fi
fi

CURRENT_CONSUL_VERSION="$(grep 'variable "consul_version"' -A2 vaultron.tf | awk '/default/ { print $3; }' | sed 's/\"//g')"

CURRENT_VAULT_VERSION="$(grep 'variable "vault_version"' -A2 vaultron.tf | awk '/default/ { print $3; }' | sed 's/\"//g')"

export TF_VAR_consul_version=${TF_VAR_consul_version:-$CURRENT_CONSUL_VERSION}
export TF_VAR_vault_version=${TF_VAR_vault_version:-$CURRENT_VAULT_VERSION}
export CONSUL_HTTP_ADDR="localhost:8500"
export VAULT_ADDR="http://localhost:8200"

export txtblu="\e[0;34m" # Blue
export txtgrn="\e[0;32m" # Green
export txtred="\e[0;31m" # Red
Expand Down Expand Up @@ -107,13 +99,12 @@ _check_consul_version
_logmsg greeting "Form Vaultron! ..."
_logmsg greeting "Consul version: ${TF_VAR_consul_version}"
_logmsg greeting "Vault version: ${TF_VAR_vault_version}"
_logmsg greeting "Set CONSUL_HTTP_ADDR to ${CONSUL_HTTP_ADDR}"
_logmsg greeting "Set VAULT_ADDR to ${VAULT_ADDR}"

if _plan; then
if _apply; then
_logmsg success "Vaultron formed!"
printf "${txtrst}"
_form_message
else
_logmsg alert "Vaultron cannot form! Check terraform apply output."
printf "${txtrst}"
Expand Down

0 comments on commit e879a47

Please sign in to comment.