Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Drupal
drupalizer
Commits
10db8314
Commit
10db8314
authored
Nov 24, 2016
by
Victor Nikulshin
Browse files
SSH-connect to Docker container as 'drupalizer' user
parent
898310e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
helpers.py
View file @
10db8314
...
...
@@ -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
)
else
:
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
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment