Using Vagrant to Manage Rimu VPS systems


Vagrant is high level wrapper around virtualization and configuration management
software. It simplifies the creation and management of easily reproduceable
environments. It is particularly suited for development and test enviroments
where servers are brought up and down frequently. It can also be used to bootstrap
production systems.

It can be used with configuration management software such as salt, puppet, chef
and others to easily provision systems.

Many software projects now ship a Vagrantfile which allows their users to quickly
setup and test the software using Vagrant.

Vagrant can now be used to manage the creation and provisioning of Rimu VPS systems,
thanks to the vagrant-rimu provider plugin.

This post will guide you on how to use vagrant to create and provision a Rimu VPS.

Requirements

In order to proceed the following requirements must be meet.

Rimu API Key

The vagrant-rimu plugin uses the Rimu REST API, so a Rimu API Key is required in
order to use the plugin. Rimu REST API keys can be generated via the Rimu
control panel

Vagrant

Of course you will have to install Vagrant on your local system. Vagrant can be
downloaded from the Vagrant website.

Installers are provided for every major operating system.

Installation

With the requirements taken care of we can now proceed to the installation of the
vagrant-rimu provider plugin.

We will first create a work space where we will store our files. You can choose
any location i have choosen to put it under ~/rimu-test-vagrant.

mkdir ~/rimu-test-vagrant
cd ~/rimu-test-vagrant

Now install the plugin.

vagrant plugin install vagrant-rimu

It is recommended you generate a SSH key pair for use with your VPS, it is good
practice to use different keys for different services. To generate a new SSH key
pair run the following commands.

ssh-keygen -t rsa -b 4096 -f ~/.ssh/rimu_rsa

With the plugin installed and keys created we can now proceed to the creation
of a Vagrantfile.

Create the Vagrantfile

To create the the Vagrantfile run the following command.

[gist https://gist.github.com/akissa/a6ce73dfe3145de77139 /]

The above is a minimal bare bones Vagrantfile and mostly uses the defaults, it
will setup a Debian 8.0 64-bit VPS in the Dallas DC, with 1512MB of memory,
4GB disk space.

The Vagrantfile also contains a minimal shell inline provisioning script which
simply creates a file ~/provision containing the word done. This is an over
simplified example of how you can use Vagrant to provision your system. For
real world provisioning you can look to the other available provisioning
plugins

The commented out options are not used, they are included to show what is
possible. The options available closely mirror the API options.

You can use the commented out options to further fine tune the installation.

Create the VPS

The Vagrantfile we created uses enviroment variables so that you do not
hard code your sensitive credentials such as the API Key in the file.

This means to use the Vagrantfile we need to set a couple of enviroment
variables:

  • RIMUHOSTING_APIKEY – This is your Rimu API Key described above.
  • RIMUHOSTING_HOSTNAME – This is the host name of the VPS, it has to be a FQDN.

So lets proceed and set those enviroment variables:

export RIMUHOSTING_APIKEY="your_api_key"
export RIMUHOSTING_HOSTNAME="enter your hostname"

With the enviroment variables in place we can now bring up our VPS:

vagrant up --provider=rimu

This will create the VPS, install your SSH key and run the provisioning
script.

Once the VPS has been created, you will be able to ssh into it directly
from Vagrant, to do so run:

vagrant ssh

You will find the file ~/provision created on the VPS indicating that the
provisioning script was run.

Simple as that.

More information

If you have not used Vagrant before, this post simply touches the surface
of how handy the tool is. I would recommend you read up on the following
resources.

You an also always turn to google and search for howto’s, tutorials, use cases
etc.

Using Vagrant you can turn a task that usually takes a few hours to a
matter of minutes as well as eliminate the human error factor.

,