Created
January 17, 2012 03:30
-
-
Save palewire/1624433 to your computer and use it in GitHub Desktop.
fab bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
from openstack.compute import Compute | |
def bootstrap(): | |
install_chef() | |
update_chef() | |
def install_chef(): | |
""" | |
Install Chef on your server | |
""" | |
sudo('apt-get update', pty=True) | |
sudo('apt-get install -y git-core rubygems ruby ruby-dev', pty=True) | |
sudo('gem install chef', pty=True) | |
def update_chef(): | |
""" | |
Update your server's software using Chef. | |
""" | |
local('rsync -av ./chef/ %s@%s:/etc/chef' % (env.user, env.hosts[0])) | |
sudo('cd /etc/chef && %s' % env.chef, pty=True) | |
def create_server(image='Ubuntu 11.04 (Natty)', flavor=256): | |
""" | |
Create a new server on Rackspace using the OpenStack API | |
""" | |
compute = Compute( | |
username=USER_NAME, | |
apikey=API_KEY | |
) | |
fl = compute.flavors.find(ram=flavor) | |
im = compute.images.find(name=image) | |
compute.servers.create(SERVER_NAME, image=im, flavor=fl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obviously, this does not include private credentials I use on my system. After I
create server
I then configure a new fabric function with its login credentials. Then runfab <serverfunction> bootstrap
.