Using Bitnami’s Rubystack on VirtualBox Linux with Vagrant
In my Software Engineering Projects class, we are going to do a RAILS-based project. Based on feedback from last year’s class, I am furnishing students with an almost configured RAILS system for development. The system is based on
- Bitnami’s Rubystack for 32 bit Linux
- VirtualBox 4.2.12 as the VM
- Vagrant 1.22 to help manage the install
- Ubuntu precise32 Linux
Create the base machine
The Vagrantfile
is configured to support networking from the host machine
and to run a configuration script (script.sh
) as part of the provisioning.
There is a small bit of logic to avoid re-provisioning things each time the
machine is brought up.
I make it by following roughly the following procedure:
- Install Virtualbox
- Install Vagrant
- Create a directory to place files add in
* The bitnami linux installer file
*
Vagrantfile
*script.sh
- Do an install:
vagrant up
- SSH into the running host:
vagrant ssh
- Use Linux as needed
- Exit back to the host OS:
exit
- Shutdown the virtual machine (saving the contents):
vagrant halt
-
Package the machine post configuration with
vagrant package default --output rails3r2e13.box
- Restart the machine and continue work:
vagrant up
Install the base machine on student computer
OS X/Linux commands are given here, change the direction of the /
(to \
) for Windows.
- Install Virtualbox
- Install Vagrant
- Create a vms directory for your development use
mkdir vms
- Create a machine1 directory
mkdir vms/machine1
It will be accessible to both Linux and your operating system. cd vms/machine1
vagrant init rails3r2e13.box url_to_image
- uncomment
config.vm.network :private_network, ip: "192.168.33.10"
in Vagrantfile vagrant up
# first time will download the vm machinevagrant ssh
# if this fails, you need to put SSH on the path
SSH for Windows
Windows does not include SSH by default. Two options are to 1) install Git locally and then use it’s SSH implementation and 2) install PuTTY.
Limitations
The file .bashrc
has a line at the end of it that maps the rails commands onto
the path along with library linkage as well. This messes up some local commands
nano
and others. One solution is to comment out the line and re-log into the
VM.
Other vagrant commands
vagrant destroy
eliminate the virtual machine so next time it will be rebuiltvagrant reload
combination of of halt then upvagrant suspend
pause machine copying state to disk, resume withvagrant resule
`
Vagrantfile
-*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: "192.168.33.10"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
config.vm.provision :shell, :path => "script.sh"
end
script.sh
#!/usr/bin/env bash
set -e # Exit script on error
set -x # Print commands and arguments
echo "Starting configuration script"
# Abort provisioning if rubystack is already installed.
test -d /opt/rubystack-1.9.3-10 &&
{ echo "rubystack already installed."; exit 0; }
echo "Provisioning rubystack from bitnami"
# Install bitnami
/vagrant/bitnami-rubystack-1.9.3-10-linux-installer.run --mode unattended \
--disable-components varnish,phpmyadmin,rvm
# install the quiet_assets gem
gem install quiet_assets -f --install-dir /opt/rubystack-1.9.3-10/ruby/lib/ruby/gems/1.9.1
# make vagrant user owner of the install
chown -R vagrant.vagrant /opt/rubystack-1.9.3-10
# install a symbolic link to rubystack directory
ln -s /opt/rubystack-1.9.3-10 /home/vagrant/rubystack
# put ruby / rails code on path
echo ". /opt/rubystack-1.9.3-10/scripts/setenv.sh" >> /home/vagrant/.bashrc
echo "Provisioning complete."
Leave a comment