Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consul-resources/templates/template-config.hcl.ctmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
consul = "{{ env "CONSUL_HOSTNAME" }}:{{ env "CONSUL_PORT" }}"

vault {
address = "http://{{ env "CONSUL_HOSTNAME" }}:8200"
address = "http://{{ env "VAULT_HOSTNAME" }}:{{ env "VAULT_PORT" }}"
token = "{{ env "VAULT_TOKEN" }}"
renew = false
}
17 changes: 15 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

export DOCK_INIT_BASE=/opt/runnable/dock-init
export HOST_IP=$(hostname -i)
source "${DOCK_INIT_BASE}/lib/util/log.sh"

if [ -z "${CONSUL_PORT+x}" ]; then
export CONSUL_PORT=8500
Expand All @@ -14,19 +15,31 @@ else
fi

if [ -z "${CONSUL_HOSTNAME+x}" ]; then
export CONSUL_HOSTNAME=10.4.5.144
log::fatal "CONSUL_HOSTNAME is not defined"
exit 1
else
export CONSUL_HOSTNAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you are here do you mind making this case exit instead?

log::fatal "CONSUL_HOSTNAME is not defined" 
exit 1

this will help with debugging in the future

fi

if [ -z "${VAULT_PORT+x}" ]; then
export VAULT_PORT=8200
else
export VAULT_PORT
fi

if [ -z "${VAULT_HOSTNAME+x}" ]; then
export VAULT_HOSTNAME=$CONSUL_HOSTNAME
else
export VAULT_HOSTNAME
fi

export DOCKER_NETWORK=172.17.0.0/16

source "${DOCK_INIT_BASE}/lib/consul.sh"
source "${DOCK_INIT_BASE}/lib/aws.sh"
source "${DOCK_INIT_BASE}/lib/dock.sh"
source "${DOCK_INIT_BASE}/lib/container.sh"
source "${DOCK_INIT_BASE}/lib/iptables.sh"
source "${DOCK_INIT_BASE}/lib/util/log.sh"

# Initializes the dock
main() {
Expand Down
4 changes: 2 additions & 2 deletions lib/vault.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vault::create_s3_policy() {
"Dock-Init: Cannot create policy template for ${bucket}" \
"Attempting to create s3 policy template. ${OUTPUT}"

export VAULT_ADDR="http://${CONSUL_HOSTNAME}:8200"
export VAULT_ADDR="http://${VAULT_HOSTNAME}:${VAULT_PORT}"
log::info "Attempting to create s3 policy template for bucket ${bucket}"

local policy_template="${DOCK_INIT_BASE}/vault-resources/s3.policy"
Expand All @@ -35,7 +35,7 @@ vault::set_s3_keys() {
"Dock-Init: Cannot create policy template" \
"Attempting to create s3 policy template. ${OUTPUT}"

export VAULT_ADDR="http://${CONSUL_HOSTNAME}:8200"
export VAULT_ADDR="http://${VAULT_HOSTNAME}:${VAULT_PORT}"
log::info "Attempting get s3 creds"
# Key Value
# lease_id aws/creds/deploy/7cb8df71-782f-3de1-79dd-251778e49f58
Expand Down