Skip to content

Commit

Permalink
Added marathon API access token key support d2iq-archive#6 d2iq-archi…
Browse files Browse the repository at this point in the history
  • Loading branch information
pawmart committed Feb 19, 2017
1 parent 39f1faa commit 113dc17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Clone (or manually copy) this repo, and modify the [letsencrypt-dcos.json](letse
- The list of hostnames (must be FQDNs) for which you want to generate SSL certs (in `HAPROXY_0_VHOST`)
- An admin email address for your certificate (in `LETSENCRYPT_EMAIL`)
- The Marathon API endpoint (in `MARATHON_URL`)
- The Marathon API access token (in `MARATHON_AUTH_TOKEN`)
- The Marathon-lb app ID (in `MARATHON_LB_ID`)
- Ensure you have **at least 2 or more** public agents in your DC/OS cluster, and that marathon-lb is scaled out to more than 1 public agent. Deploying this app requires this since it entails restarting marathon-lb.

Expand Down
12 changes: 8 additions & 4 deletions post_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import requests
import time

url = os.environ.get('MARATHON_URL')
base_url = os.environ.get('MARATHON_URL')

marathon_lb_id = os.environ.get('MARATHON_LB_ID')
marathon_lb_cert_env = \
os.environ.get('MARATHON_LB_CERT_ENV', 'HAPROXY_SSL_CERT')

print("Retrieving current marathon-lb cert")
sys.stdout.flush()
r = requests.get(url + '/v2/apps/' + marathon_lb_id)

headers = {'Authorization': 'token=' + os.environ.get('MARATHON_AUTH_TOKEN')}
marathon_lb_url = base_url + '/v2/apps/' + marathon_lb_id
r = requests.get(marathon_lb_url, headers=headers)
mlb = r.json()
env = mlb['app']['env']
cert = ''
Expand All @@ -29,7 +33,7 @@
print("Deploying marathon-lb with new cert")
sys.stdout.flush()
headers = {'Content-Type': 'application/json'}
r = requests.put(url + '/v2/apps/' + marathon_lb_id,
r = requests.put(marathon_lb_url,
headers=headers,
data=json.dumps({
'id': marathon_lb_id,
Expand All @@ -43,7 +47,7 @@
time.sleep(5)
print("Waiting for deployment to complete")
sys.stdout.flush()
r = requests.get(url + '/v2/deployments')
r = requests.get(base_url + '/v2/deployments')
deployments = r.json()
deployment_exists = False
for deployment in deployments:
Expand Down
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -e
# Wait to settle
sleep 15

# Get our SSL domains from the Marathon app label
#SSL_DOMAINS=${SSL_DOMAINS}
# Get our SSL domains from env variable
SSL_DOMAINS=${SSL_DOMAINS}

IFS=',' read -ra ADDR <<< "$SSL_DOMAINS"
DOMAIN_ARGS=""
Expand Down

0 comments on commit 113dc17

Please sign in to comment.