Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Get --auth-credentials from a VAULT instance #432

Merged
merged 3 commits into from
Mar 31, 2017

Conversation

albertostratio
Copy link
Contributor

As you might know if your Marathon requires authentication it is possible to pass in the auth-credentials parameter to marathon_lb.py in order to get authorized.

This PR includes the changes to get the user & password from a running VAULT instance defining environment variables. If this PR gets approved we will able to add these variables to the config.json of the marathon-lb package in the DC/OS universe.

Copy link
Contributor

@robsonpeixoto robsonpeixoto left a comment

Choose a reason for hiding this comment

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

if [ -n "${VAULT_TOKEN-}" ] && [ -n "$VAULT_URL-" ]; then
  MARATHON_LB_USER=$(curl -k -L -H "X-Vault-Token:$VAULT_TOKEN" "$VAULT_URL" -s | jq -r '.data .user')
  MARATHON_LB_PASSWORD=$(curl -k -L -H "X-Vault-Token:$VAULT_TOKEN" "$VAULT_URL" -s | jq -r '.data .pass')
  CREDENTIALS="$MARATHON_LB_USER:$MARATHON_LB_PASSWORD"
  ARGS="$ARGS --auth-credentials $CREDENTIALS"
fi

It's only tips. I'm not a marathon-lb developer.

run Outdated
@@ -88,6 +88,13 @@ case "$MODE" in
;;
esac

if [ -n "${VAULT_TOKEN-}" ] && [ -n "${VAULT_HOST-}" ] && [ -n "${VAULT_PORT-}" ] && [ -n "${VAULT_PATH-}" ]; then
export MARATHON_LB_USER=$(curl -k -L -H "X-Vault-Token:$VAULT_TOKEN" "https://$VAULT_HOST:$VAULT_PORT$VAULT_PATH" -s | jq -r ".data .\"user\"")
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to install jq

Copy link
Contributor

Choose a reason for hiding this comment

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

The jq can simplified: | jq -r '.data.user'

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO you do need of all theses env vars: https://$VAULT_HOST:$VAULT_PORT$VAULT_PATH
Replace all with VAULT_URL

Copy link
Contributor

Choose a reason for hiding this comment

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

And you do not need to export the variables MARATHON_LB_USER, MARATHON_LB_PASSWORD and CREDENTIALS.

Marcos P and others added 2 commits March 17, 2017 14:26
@albertostratio
Copy link
Contributor Author

Thank you for your comments @robsonpeixoto , my colleague @MPenate have made some changes to get rid of the jq dependency. I like your suggestion regarding the unique VAULT_URL, I'll add these changes ASAP.

@albertostratio
Copy link
Contributor Author

Anyone from Mesosphere could please have a look at this PR? Thank you in advance.

@lloesche
Copy link
Contributor

Thank you for the PR!

LGTM 🚢

@lloesche lloesche merged commit 8811443 into d2iq-archive:master Mar 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants