mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Restructuring fabfile to use dynamic hosts.
This commit is contained in:
parent
52094da61f
commit
7afd2ff946
4 changed files with 12 additions and 34 deletions
|
@ -25,6 +25,7 @@ oauth2==1.5.211
|
|||
PIL==1.1.7
|
||||
psutil==0.6.1
|
||||
pyes==0.19.1
|
||||
pyelasticsearch==0.5
|
||||
pyflakes==0.6.1
|
||||
pymongo==2.2
|
||||
python-dateutil==1.5
|
||||
|
|
4
fabfile.py
vendored
4
fabfile.py
vendored
|
@ -97,6 +97,10 @@ def work():
|
|||
do()
|
||||
env.roles = ['work']
|
||||
|
||||
def www():
|
||||
do()
|
||||
env.roles = ['www']
|
||||
|
||||
def dev():
|
||||
do()
|
||||
env.roles = ['dev']
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
raven
|
||||
mongoengine
|
||||
pyyaml
|
||||
lxml
|
||||
feedparser
|
||||
celery
|
||||
django
|
||||
redis
|
||||
nltk
|
||||
django-extensions
|
||||
pyes
|
||||
stripe
|
||||
cssutils
|
||||
django-subdomains
|
||||
python-gflags
|
|
@ -4,13 +4,11 @@ import os
|
|||
import select
|
||||
import subprocess
|
||||
import sys
|
||||
import yaml
|
||||
import dop.client
|
||||
from django.conf import settings
|
||||
|
||||
sys.path.append('/srv/newsblur')
|
||||
sys.path.insert(0, '/srv/newsblur')
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||
import fabfile
|
||||
|
||||
IGNORE_HOSTS = [
|
||||
'push',
|
||||
|
@ -23,27 +21,17 @@ def main(role="app", role2="dev", command=None, path=None):
|
|||
if not command:
|
||||
command = "tail -f"
|
||||
|
||||
hosts_path = os.path.expanduser(os.path.join('../secrets-newsblur/configs/hosts.yml'))
|
||||
hosts = yaml.load(open(hosts_path))
|
||||
|
||||
for r in [role, role2]:
|
||||
if r not in hosts:
|
||||
hosts[r] = []
|
||||
if isinstance(hosts[r], dict):
|
||||
hosts[r] = ["%s:%s" % (hosts[r][k][-1], k) for k in hosts[r].keys()]
|
||||
fabfile.do(split=True)
|
||||
hosts = fabfile.env.roledefs
|
||||
|
||||
doapi = dop.client.Client(settings.DO_CLIENT_KEY, settings.DO_API_KEY)
|
||||
droplets = doapi.show_active_droplets()
|
||||
for droplet in droplets:
|
||||
if role in droplet.name or role2 in droplet.name:
|
||||
hosts[role].append("%s:%s" % (droplet.name, droplet.ip_address))
|
||||
|
||||
for hostname in set(hosts[role] + hosts[role2]):
|
||||
if any(h in hostname for h in IGNORE_HOSTS): continue
|
||||
if ':' in hostname:
|
||||
hostname, address = hostname.split(':', 1)
|
||||
elif isinstance(hostname, tuple):
|
||||
hostname, address = hostname[0], hostname[1]
|
||||
else:
|
||||
address = hostname
|
||||
if any(h in hostname for h in IGNORE_HOSTS): continue
|
||||
if 'ec2' in hostname:
|
||||
s = subprocess.Popen(["ssh", "-i", os.path.expanduser("~/.ec2/sclay.pem"),
|
||||
address, "%s %s" % (command, path)], stdout=subprocess.PIPE)
|
||||
|
|
Loading…
Add table
Reference in a new issue