Less than 5 Minute Aegir Slave Server on Amazon EC2 - Bash Script and Notes

I've started using Amazon EC2 with Aegir's multiple server setup and its sweeeet.  I can add a new server to my Aegir setup in like 2 minutes.

My bash script

Here is the script: http://pastebin.com/hHnTDtzs

I've tested this script with ami-3e02f257.   These are its specs:

  • Ubuntu 10.04
  • 32bit
  • EBS Store (allows this to be "micro" compatable and easy to backup/clone.)

I don't see why the script wouldn't work with x64... I just didn't test that.

What it does

You can read through the script and see all the commads that it does but here is a quick summary:

  • Runs apt-get update and upgrade
  • Installs everything you need plus git and nano
  • Forces php to be 5.2 rather than 5.3 using approach #3 here.
  • Does almost everything you need to do in the manual aegir install for using the server as an slave host.  Sets memory limits, comments bind-address, creates aegir user, creates aegir_root mysql user, etc...
  • Installs pecl uploadprogress
  • Installs Drush

What it doesn't do

It DOES NOT configure your hosts file or your rc.local file.  You need to do both to get a FQDN (fully qualified domain name).

I add my ip (you will need an Elastic IP set in AWS console for your server instance) and domain name to /etc/hosts like so:

127.0.0.1 localhost
50.17.186.31 aegirslave1.mydomain.com aegirslave1 #line I added

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

You also want to add a hostname aegirslave1.mydomain.com      to your /etc/rc.local right before the exit 0.

Logging into your slave from your master

You need to copy your ssh key from your aegir master to your slave.  I do that like so:

  • Copy the amazon key (example: yourkeyname.pem) to your master server however you wish, via ssh or ftp.
  • SSH into your to your master aegir server.... copy the id_rsa.pub file to your AMI instance:
    • scp -i /path/to/amikey/yourkeyname.pem /path/to/aegirserverkey/id_rsa.pub ubuntu@aegirslave1.yourdomain.com:~/
  • Back at your ami instance terminal:
    • sudo chown aegir:aegir id_rsa.pub
    • sudo cp id_rsa.pub /var/aegir/.ssh/authorized_keys
  • Back at your master server, test the login:
  • ssh aegir@aegirslave1.yourdomain.com

Finished and Future 2 Minute Installs...

Reboot and your done. 

Now before you go and add this to your "main" aegir install (in the web ui).  You should use Amazon AWS Console to clone your setup server:

  • Right click on yoru console and click the "Create Image (EBS AMI)"

  • Whenever you want a new server, you can create a new instance with that AMI... one that:
    • already has everything you need installed
    • has your aegir master ssh key (so you can instantly login to it)
    • only needs the hosts and rc.local file re-setup for you new IP and FQDN

Last Quick Tip

Use drush make files for your platforms.  That way, after you setup your newest Aegir slave host, you can put an Aegir platform on it AND add sites to it without touching the console again.  You can do it straight from the web UI. 

Here is a platform I have.  It uses a make file I have located at: /var/aegir/gitdev/build/stsbase/stsbase.make in my MASTER server.  I fill out the fields.. Aegir does the work :).

 

My notes from testing

I stuck my notes on pastebin, just so I have something to look back on.  They are basically a bunch of commands I always forget and how to do stuff I always forget how to do :). 

http://pastebin.com/JRHQ2b1A

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

just one thing for noobs like me :
if you don't have a id_rsa.pub in /root/.ssh
you have to generate-it :
ssh-keygen -t rsa

after copy you new file to /path/to/aegirserverkey/

you have to chmod your /path/to/aegirserverkey/yourkeyname.pem to 600

Hi,
many thanks for your script and your tutorial,
i've got a question about the configuration of the FQDN. Is this domain could be the same of the master aegir server ?
Ie : Master FQDN > www.mydomain.com
Slave EC2 Aegir > slave1.mydomain.com
thanks.

Post new comment