-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfabfile.py
47 lines (35 loc) · 1.44 KB
/
fabfile.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
36
37
38
39
40
41
42
43
44
45
from fabric.api import run
from fabric.api import hosts, local, settings, abort
from fabric.state import env
import os
def process_proxy_host():
""" Post-process a proxy host """
with settings(warn_only=True):
run("sudo iptables-restore < /etc/iptables.rules")
run("sudo squid3 -f /etc/squid3/squid.conf")
def iptables_apply():
""" Apply iptables rules from /etc/iptables.rules """
with settings(warn_only=True):
run("sudo iptables-restore < /etc/iptables.rules")
def proxy_iptables():
""" Apply iptables rules on all proxy nodes """
# get proxy list from proxylb
local('scp alpha@proxylb:proxyrotate/proxies.list .')
if os.path.isfile('proxies.list'):
for line in open('proxies.list'):
ip = line.strip().split(',')[0].strip()
env.host_string = ip
env.user = 'alpha'
print 'Restoring iptables rules on',ip,'...'
run('sudo iptables-restore < /etc/iptables.rules')
def install_keys():
""" Install an ssh key to all proxy nodes """
# get proxy list from proxylb
local('scp alpha@proxylb:proxyrotate/proxies.list .')
if os.path.isfile('proxies.list'):
for line in open('proxies.list'):
ip = line.strip().split(',')[0].strip()
env.host_string = ip
env.user = 'alpha'
local('scp id_rsa.pub alpha@%s:' % ip)
run('cat id_rsa.pub >> .ssh/authorized_keys')