Last active
August 29, 2015 13:57
-
-
Save drefined/9420767 to your computer and use it in GitHub Desktop.
Bootstrap Instance with etcd
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
#!/usr/bin/env python | |
import base64 | |
import etcd | |
import os | |
if __name__ == "__main__": | |
etcd_deploy_key = os.getenv('ETCD_DEPLOY_KEY', '/ssh/private/_deploy') | |
etcd_gateway_key = os.getenv('ETCD_GATEWAY_KEY', '/ssh/public/gateway') | |
registry_host = os.getenv('REGISTRY', 'localhost') | |
etcd = etcd.Client(host=registry_host) | |
deploy_key = base64.b64decode(etcd.get(etcd_deploy_key).value) | |
gateway_key = base64.b64decode(etcd.get(etcd_gateway_key).value) | |
id_rsa = '/home/ubuntu/.ssh/id_rsa' | |
f = open(id_rsa, 'w') | |
f.write(deploy_key) | |
f.close() | |
os.chmod(id_rsa, 0600) | |
authorized_keys = '/home/ubuntu/.ssh/authorized_keys' | |
f = open(authorized_keys, 'w') | |
f.write(gateway_key) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment