Authors: @smangelsdorf and @bradleybeddoes
Spin up multiple Linux nodes via VirtualBox and Kickstart for developers working from OSX.
Now with more mitchellh/vagrant goodness, supplying the Vagrant public key by default for root SSH access.
If you find this useful you're of course welcome to buy us 🍻 and 🍕.
- Install the latest release of Virtualbox
- Setup a Host-only Network called vboxnet0 using the IP range 192.168.56.0/24. We find most development nodes are better suited to using static IP so tend to set the DHCP range from 192.168.56.201 to 192.168.56.254 with a server address of 192.168.56.200 (even this is probably excessive)
-
Install homebrew
-
Install the cdrtools formula
$> brew install cdrtools
-
Install rbenv
$> brew install rbenv $> brew install ruby-build
Be sure to add the appropriate line to your ~/.bash_profile as shown in the installer output then reload it.
$> rbenv install 2.0.0-p247 $> rbenv global 2.0.0-p247 # optional you may like to set this locally with rbenv local instead
-
Install bundler
$> gem install bundler
-
Clone stratus to your machine
$> git clone git@github.com:bradleybeddoes/stratus.git $> cd stratus
-
Setup stratus with basic directives for your machine.
$> cp setup.dist setup
Edit this file to suit your local way of working. Each option is commented inline.
-
Setup environment for kickstart server
$> cd kickstartserver && bundle install && cd ..
We've tested this using the CentOS 6.[4,5] minimal ISO. It will probably work for other distributions without much bother. Ubuntu is next on the list to officially support.
To build a CentOS 6.5 ISO:
$> bash scripts/automate_iso
If CentOS 6.5 isn't to your liking the script offers a number of options:
$> bash scripts/automate_iso -h
When you're spinning up new machines it is important to have the kickstart server running in the background. This is just a very basic sinatra app running in unicorn that maps a machines MAC addresses to kickstart files.
$> cd kickstartserver;
$> bundle exec unicorn;
Once you have your iso is built you only need a few details to get a new machine running. By default the Vagrant public key mitchellh/vagrant/tree/master/keys is authorized for login as root on the new machine. Add any additional public keys you'd like to authorize to keys/authorized_keys
$> bash scripts/create_machine -n <machine name> -a <ip address>
e.g.
$> bash scripts/create_machine -n db1 -a 192.168.56.10
… once vm is running …
$> ssh root@192.168.56.10
This process publishes a file to kickstartserver/files/<mac>.ks
. Once the file has been served to a machine to complete its kickstart process the file is renamed kickstartserver/files/<mac>.ks.served
so you can clean these up at some future time.
Once the create machine process has completed it will appear in your Virtualbox management UI and you can manage it as normal. You want to use this to create a Vagrant base box.
Once again the script offers a number of options:
$> bash scripts/create_machine -h
The -x to automatically startup the new machine after provisioning and -g options are particularly useful.
If you're planning on shipping this as a Vagrant base box or just want to do things like shared directories you'll want to additionally install the Virtualbox guest additions:
- Run
yum update kernel*
- Reboot the VM
- Install required packages
yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
- Set kernel source dir
export KERN_DIR=/usr/src/kernels/`uname -r`
- Grab the x86_64 RPM for the latest VirtualBox guest tools currently http://download.virtualbox.org/virtualbox/4.3.10/
- Install the VirtualBox RPM
yum install <downloaded rpm>
If you'd like to spin up multiple machines undertake the following steps:
-
Create a
machines.csv
file frommachines.csv.dist
. Here is an example:app1,192.168.56.20,myorg/applications,false app2,192.168.56.21,myorg/applications,false app3,192.168.56.22,myorg/applications,false db1,192.168.56.23,myorg/cluster,false db2,192.168.56.24,myorg/cluster,false
-
Run the multiple machines script
$> bash scripts/create_multiple_machines
For a really fun experience set all the execute flags to true . This script could be quite easily extended for more advanced cases.
To enable auto population of your ~/.ssh/config file with name and IP of the machines you create do the following:
- Checkout ssh-config command line tools and add to your path
- In your setup file change update_ssh to be true
- Build machines!