Skip to content

Instantly share code, notes, and snippets.

@benjvi
Created May 28, 2019 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjvi/1648c279742dcbef91a9ecce05bacf94 to your computer and use it in GitHub Desktop.
Save benjvi/1648c279742dcbef91a9ecce05bacf94 to your computer and use it in GitHub Desktop.
# depends on:
# CLIs: bosh, fly, credhub, om
# aliases: bosh_env_aliases (another of my gists)
alias fly='fly -t concourse'
alias whichom="env | grep -i om_"
alias ch=credhub
fly-cp-login() {
# arg[1] - control plane external url (no port)
# login to bosh first
bosh-om-setup-env
# check bosh contains a concourse
bosh deployments --column="Release(s)" | ( grep concourse || echo "No concourse release found, wrong BOSH?" && return )
url="$(bosh manifest -d control-plane | yq -r '.instance_groups[0].jobs[0].properties.external_url')"
fly login -c "$url" $@
}
fly-cp-show-admin-pw() {
# arg[1] - control plane external url (no port)
# login to bosh first
bosh-om-setup-env
# check bosh contains a concourse
bosh deployments --column="Release(s)" | ( grep concourse || echo "No concourse release found, wrong BOSH?" && return )
credhub get -n /p-bosh/control-plane/uaa_users_admin -j | jq -r .value
}
credhub-cp-login() {
# arg[1] - control plane external url (no port)
# login to bosh first (this fn is in bosh_env_aliases)
bosh-om-setup-env
# check bosh contains a concourse
bosh deployments --column="Release(s)" | ( grep concourse || echo "No concourse release found, wrong BOSH?" && return )
ch_secret="$(credhub get -n /p-bosh/control-plane/credhub_admin_client_password -j | jq -r .value)"
ch_ca_cert="$(credhub get -n /p-bosh/control-plane/control_plane_tls -k ca)"
export CREDHUB_CLIENT=credhub_admin_client
export CREDHUB_SERVER="$1:8844"
export CREDHUB_SECRET="$ch_secret"
export CREDHUB_CA_CERT="$ch_ca_cert"
unset CREDHUB_PROXY
credhub login
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment