forked from jacobian/django-deployment-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
41 lines (33 loc) · 1.22 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
"""
This is my private fabfile I use to automate parts of the teaching of the
class. It doesn't really serve any pedagogical purpose; see the fabiles in
``fabfiles/`` for better examples.
"""
import os
import cloudservers
from fabric.api import *
from fabric.contrib import files
from unipath import FSPath as Path
CS = cloudservers.CloudServers(os.environ['CLOUD_SERVERS_USERNAME'],
os.environ['CLOUD_SERVERS_API_KEY'])
env.hosts = ['oscon-web1', 'oscon-web2', 'oscon-db1']
env.user = 'root'
def bootem():
servers = []
flavor = CS.flavors.find(ram=256)
image = CS.images.find(name="Ubuntu 10.04 LTS (lucid)")
for name in env.hosts:
server = CS.servers.create(name, flavor=flavor, image=image)
servers.append(server)
print "%s: ips: %s/%s pass: %s" % (name, server.public_ip, server.private_ip, server.adminPass)
def copyid():
for name in env.hosts:
local('ssh-copy-id %s' % name)
def setup():
run('aptitude update && aptitude -y safe-upgrade')
run('aptitude -y install bash-completion language-pack-en')
run('echo ". /etc/bash_completion" >> .bashrc')
def killem():
for name in env.hosts:
CS.servers.find(name=name).delete()
del Path