-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfabfile-example.py
35 lines (29 loc) · 1.13 KB
/
fabfile-example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from fabric.context_managers import cd
from fabric.context_managers import lcd
from fabric.decorators import task
from fabric.operations import local
from fabric.operations import put
from fabric.operations import sudo
from fabric.state import env
# Super simple deployment script. Assumes you've placed apache2 in front of it
# Just setup:
#
# env.hosts -- where you deploy
# ROOT_PATH -- the dir you installed botanist
# USER -- the user you installed botanist under
env.colorize_errors = True
env.use_ssh_config = True # super handy, uses your ~/.ssh/config
env.hosts = ['TBD']
ROOT_PATH = '/srv/botanist'
USER = 'botanist'
@task
def deploy_webapp():
with lcd('webapp'):
local('find . -name "*.pyc" -exec rm {} \;')
local('tar --exclude=webapp/.idea --exclude=webapp/.venv --exclude=webapp/atlassian-ide-plugin.xml --exclude=webapp/*.conf -czf webapp.tar.gz webapp/')
with cd(ROOT_PATH):
put('webapp.tar.gz', '.', use_sudo=True)
sudo('tar zxvf webapp.tar.gz', user=USER, group=USER)
sudo('rm -rf webapp.tar.gz', user=USER, group=USER)
local('rm webapp.tar.gz')
sudo('service apache2 restart')