Last active
August 27, 2019 23:53
-
-
Save kbruner/45b6dd875a1b04b4d46220969aa26a0e to your computer and use it in GitHub Desktop.
DC/OS OSS Automated Initial Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Note: this only works for OSS DC/OS >= 1.13 | |
# <generate your Terraform configuration for the Installer> | |
terraform init | |
terraform apply -auto-approve -input=false | |
master_ip="$(terraform output -json | jq -r '.["masters-ips"].value[0]')" | |
master_lb_ip="$(terraform output -json | jq -r '.["cluster-address"].value')" | |
# Don't judge me. | |
password=password | |
pw_hash="$(echo "$password" | \ | |
python3 -c 'from passlib.hash import sha512_crypt; print(sha512_crypt.hash(input().rstrip()))' | \ | |
sed -e 's/\$/\\\$/g')" | |
# Set your key path below (or remote the option if you have ssh-add-ed the key) | |
# Change the OS Username if not using CentOS (installer default) | |
echo "SSH to master to add IAM user" | |
ssh -4 -o "UserKnownHostsFile=/dev/null" \ | |
-o "StrictHostKeyChecking=no" \ | |
-o "ServerAliveInterval=120" \ | |
-i "/path/to/my/id_rsa" \ | |
"centos@$master_ip" \ | |
'/opt/mesosphere/active/cockroach/bin/cockroach sql \ | |
--insecure \ | |
--url "postgresql://$(cat /var/lib/dcos/cockroach/cockroach.listen-addr)/" \ | |
--execute "insert into iam.users (uid, passwordhash, utype, is_remote, provider_type) values ('\''myuser'\'', '\'"$pw_hash"\'', '\''regular'\'', false, '\''internal'\'');"' | |
# Authenticate! | |
echo "Run dcos cluster setup" | |
dcos cluster setup --provider dcos-users \ | |
--username myuser \ | |
--password "$password" \ | |
--insecure \ | |
"https://${master_lb_ip}/" | |
# ... finish dcos cluster setup from CLI | |
echo "You probably want to change the password for myuser now..." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment