Commit 75c66567 authored by Christos Stavrakakis's avatar Christos Stavrakakis

ci: Copy ssh keys

Add option for copying ssh keys to the created vm.
parent d5b90719
......@@ -203,6 +203,7 @@ class SynnefoCI(object):
server = self._wait_transition(server_id, "BUILD", "ACTIVE")
self._get_server_ip_and_port(server)
self._copy_ssh_keys()
self.setup_fabric()
self.logger.info("Setup firewall")
......@@ -252,6 +253,20 @@ class SynnefoCI(object):
self.write_config('server_port', server_port)
self.logger.debug("Server's ssh port is %s" % _green(server_port))
@_check_fabric
def _copy_ssh_keys(self):
authorized_keys = self.config.get("Deployment",
"ssh_keys")
if os.path.exists(authorized_keys):
keyfile = '/tmp/%s.pub' % fabric.env.user
_run('mkdir -p ~/.ssh && chmod 700 ~/.ssh', False)
fabric.put(authorized_keys, keyfile)
_run('cat %s >> ~/.ssh/authorized_keys' % keyfile, False)
_run('rm %s' % keyfile, False)
self.logger.debug("Uploaded ssh authorized keys")
else:
self.logger.debug("No ssh keys found")
def write_config(self, option, value, section="Temporary Options"):
"""Write changes back to config file"""
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment