-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.py
More file actions
66 lines (50 loc) · 1.7 KB
/
Copy pathdeploy.py
File metadata and controls
66 lines (50 loc) · 1.7 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
import os
from fabric.api import *
from fabric.contrib.files import is_link, exists
from fabtools import git
from fabtools.files import symlink
from fabtools import supervisor
from fabtools.require import rpm, directory
from fabtools.python import virtualenv, install
import time
local_config_dir = "./config"
remote_config_dir = "/etc/supervisor.d"
app_dir = "/opt/router_log_parser"
app_repo = "https://github.com/hawk1278/router_log_parser.git"
now = time.strftime("%d-%m-%Y-%H-%M-%S", time.gmtime())
pkg_list = ['python-pip','git','python-virtualenv']
env.roledefs = {
'appserver':['192.168.1.22']
}
env.warn_only = True
env.ssh_config = True
def clone_repo():
with cd(app_dir):
sudo("git clone {0} {1}".format(app_repo, now))
def create_link():
with cd(app_dir):
if is_link(os.path.join(app_dir, "current")):
sudo("rm -f {0}".format(os.path.join(app_dir, "current")))
symlink(os.path.join(app_dir, now), "current", use_sudo=True)
def configure_supervisor():
directory(remote_config_dir, use_sudo=True)
if exists(os.path.join(remote_config_dir, "router_log_parser.conf")) is False:
with lcd(local_config_dir):
with cd(remote_config_dir):
put("./router_log_parser.conf", "./", use_sudo=True)
supervisor.update_config()
def create_venv():
with cd(os.path(now,"current")):
sudo("virtualenv router_log_parser_env")
with virtualenv("router_log_parser_env"):
install("pymongo")
def install_reqs():
for pkg in pkg_list:
rpm.install(pkg, options="--quiet")
sudo('pip install supervisor')
@task
def deploy(default=True):
pass
def run_app():
pass