Commit 10db8314 authored by Victor Nikulshin's avatar Victor Nikulshin
Browse files

SSH-connect to Docker container as 'drupalizer' user

parent 898310e6
......@@ -18,12 +18,14 @@
from __future__ import unicode_literals
import os
import socket
from getpass import getuser
from fabric.api import lcd, cd, roles, local, run
from fabric.colors import green
from fabric.context_managers import settings
from fabric.contrib.console import confirm
from fabric.contrib.files import exists
......@@ -43,7 +45,7 @@ host_name = local("hostname", capture=True)
# Set the env dict with the roles and the hosts
env.roledefs['local'] = ["{}@{}".format(user_name, host_name)]
env.roledefs['docker'] = ["root@{}".format(env.container_ip)]
env.roledefs['docker'] = ["drupalizer@{}".format(env.container_ip)]
env.builddir = path.join(env.workspace, 'build')
......@@ -68,7 +70,8 @@ def fab_run(role="local", cmd=""):
if role == "local":
return local(cmd)
return run(cmd)
with settings(key_filename=fab_path("docker/ssh/id_rsa")):
return run(cmd)
def fab_cd(role, directory):
......@@ -200,3 +203,12 @@ def init_db(role='docker'):
'\'{}\'@\'localhost\' IDENTIFIED BY \'{}\'; GRANT ALL PRIVILEGES ON {}.* TO \'{}\'@\'{}\' '
'IDENTIFIED BY \'{}\'; FLUSH PRIVILEGES;"'.format(env.site_db_name, env.site_db_name, env.site_db_user, env.site_db_pass,
env.site_db_name, env.site_db_user, docker_iface_ip, env.site_db_user))
def fab_path(filename):
Returns the full path a file relative to the location of fabfile.
:param filename Name of the file to compose path from.
path = os.path.dirname(os.path.abspath(__file__))
return os.path.abspath('{0}/{1}'.format(path, filename))
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