Frigg - libcloud-based script to create a VPS and install Aegir in one hit
I've been playing with Libcloud out of interest, and as a method of learning its ins and outs, I've written a script called 'Frigg'.
Frigg is named after a Norse goddess (uh oh, here it comes..) and is designed to spin up a brand new server in the cloud, and then install Aegir on it.
All you have to is run 'python frigg' from a machine somewhere after configuring the frigg.ini file with the usual Aegir parameters (use '0.4-beta1' for version, for example) and your VPS provider and api key info, and you'll get the 'Welcome' one-time Login url e-mail for your new Aegir installation on your new server just a couple of minutes later. That's it!
You can get Frigg via github by running git clone git://github.com/mig5/frigg.git.
To run it, you'll need python, python-paramiko and libcloud. To get libcloud, I simply did a git clone git://github.com/apache/libcloud.git and ran python setup.py install . You can also use my fork at git://github.com/mig5/libcloud.git, which has someone's patch to allow the root user's password to be caught when using deploy_node (it normally only does so for create_node)
Currently the default provider in the frigg.ini is Rackspace. However, I have tried to abstract the provider away in the code, which means any VPS provider supported by libcloud should be supported, so long as that provider implementation supports the deploy_node method. I am not sure that they all do.
I am assuming the MySQL host is localhost (the default in Aegir 0.4-beta1) and I am not yet commenting out the bind-address directive in the mysql my.cnf. So it's probably not 'remote server' friendly if you want your remote web servers to talk back to the main server for database communication. I might add that later.
A random MySQL root user password is generated. It is printed to stdout on completion, and you'll be able to retrieve this from the /var/aegir/.drush/server_localhost.drushrc.php alias file.
You'll need an SSH private/public keypair in the .ssh directory of the user you're executing frigg as, because the public key will be copied up to the new VPS so that you can login without requiring a password.
Also, the code is completely hardcoded to deploy a Debian based system (a lot of apt-get etc). I won't apologise for that, too bad :)
It's just for fun at this stage and it needs some sanity checking etc of the inputs, but you're welcome to try it and improve on it if you like :)

Comments
daco
Wed, 01/12/2010 - 00:51
Permalink
Nice! Thanks for sharing!
Nice! Thanks for sharing!
jpstrikesback
Wed, 01/12/2010 - 01:47
Permalink
Frigg-ing awesome!!!
Frigg-ing awesome!!!
patcon
Wed, 01/12/2010 - 01:50
Permalink
You're amazing miguel! I
You're amazing miguel! I just sucked it up and acquired a linode last night, with the intention of getting a grip on doing some real Aegir work, and this is unimaginably great! I suppose I should learn to get my own install going at some point, if only to understand, but I'll give this a spin tonight.
Thanks again!
mig5
Wed, 01/12/2010 - 10:02
Permalink
I haven't tested this with
I haven't tested this with Linode yet, but I've just taken a look at the API implementation and it appears a little different.
http://blog.linode.com/2009/09/14/full-libcloud-support/
There's no 'user' element to the connection, only a single API key, so you may find it simply doesn't work in Frigg.
I'll see what I can do to abstract even the connection arguments and not just the driver (provider).
mig5
Wed, 01/12/2010 - 10:11
Permalink
Also the Linode
Also the Linode implementation depends on python-json and the responses come back in json which is totally different again to what Frigg currently does. It looks like I have some work to do :)
patcon
Thu, 02/12/2010 - 06:03
Permalink
Oh jeez, don't worry about it
Oh jeez, don't worry about it Miguel! I'm working on osx and running into issues even before I hit that, so dont rush anything on my account. Thanks though :)
For anyone else on OS X:
The macport of py-paramiko depends on python24, but it seems libcloud needs python26 to install, so I'm not sure where this leaves us. Plus, like Miguel mentioned, python-json is needed, but that is exclusive to python26 (although there is simplejson). This is all a little over my head for someone who doesn't know python, but I thought I'd share!
There's a discussion of python version requirements for libcloud (with some favouring python26 for its json support), and linode is mentioned, so it might be relevant to anyone going down this road.
patcon
Fri, 03/12/2010 - 13:58
Permalink
I got it working by just
I got it working by just junking around with your code, but I just realized that Linode charges me a couple of bucks every time I spin up a node, so I switched to rackspace anyhow :)
Thanks though Miguel
patcon
Fri, 03/12/2010 - 16:25
Permalink
IT WORKS! You, Miguel, are a
IT WORKS! You, Miguel, are a wonderful, magical man.
Say... I will totally mail you some sort of amazing treasure if you send me your mailing address. No bullshit. I'm feeling Reddit-y. Like maybe little tiny miniature pancakes. Or bees. Or something.
patcon
Fri, 03/12/2010 - 17:39
Permalink
Hmmm... spoke too soon. Seems
Hmmm... spoke too soon. Seems I'm hitting the same snag as this guy who ended up having to build from scratch with the INSTALL. Dah well, probably for the best that I'll be headed that route.
Add new comment