Rapid Deployment of a Development Environment
To avoid the high costs of deploying development and testing environments that are close to the development stage (development stage vs production stage parity ), environment virtualization is becoming increasingly popular.
In this article, I will describe how I created the appropriate reproducible development environment using my runit-man project using Vagrant as an example .
First we need to install VirtualBoxand Vagrant himself. It is important to note that VirtualBox is highly recommended to be installed along with the Guest Extensions of the same version, otherwise the deployment will be unstable. Since I am developing for MacOS X, it was important that there are no corresponding guest extensions for the latest version of VirtualBox. Therefore, I had to install VirtualBox 4.1.0 together with Vagrant 1.0.1.
Next, I used the image of the Ubuntu OS (I basically did not care which OS to use at this stage) under the name lucid32.
Then he went to the project directory runit-man, and executed
On the target system, we will need to deploy runit, the runit-man project from the master branch of the source repository and run the runit-man service on port 14500, which must be forwarded to port 14500 of the main operating system for easy testing through the browser.
Any system image prepared for use with Vagrant already includes ruby, and is ready for deployment through Chef, Puppet, or other tools.
The easiest way for me was to use Chef in Solo mode, which does not require installing a Chef server.
Accordingly, he created the cookbooks folder, where he created a collection of provisioning recipes.
Now Vagrantfile has acquired the following form:
To deploy runit, I put a collection of runit recipes (downloaded from GitHub ) in the cookbooks directory .
Accordingly, we need to indicate that the provisioning collection depends on the runit collection (cookbooks / provisioning / metadata.rb):
It's time to deploy an empty installation through
To do this, we will need to deliver the necessary gems through the Bundler, install Git and deploy the repository and runit-man service (cookbooks / provisioning / recipes / default.rb):
The definition of runit_service will automatically install runit and create the runit-man service using the templates we provide.
run-script (cookbooks / provisioning / templates / default / sv-runit-man-run.erb):
log-run-script (cookbooks / provisioning / templates / default / sv-runit-man-log-run.erb).
This is where the initial deployment of the environment is completed (in my case, I needed an environment to check the runit-man in various boundary cases, development is not conducted in this environment, so packages for development were not installed).
Now you can run
An additional bonus: the same set of recipe collections can also be used to deploy operating environments.
References:
In this article, I will describe how I created the appropriate reproducible development environment using my runit-man project using Vagrant as an example .
First we need to install VirtualBoxand Vagrant himself. It is important to note that VirtualBox is highly recommended to be installed along with the Guest Extensions of the same version, otherwise the deployment will be unstable. Since I am developing for MacOS X, it was important that there are no corresponding guest extensions for the latest version of VirtualBox. Therefore, I had to install VirtualBox 4.1.0 together with Vagrant 1.0.1.
Next, I used the image of the Ubuntu OS (I basically did not care which OS to use at this stage) under the name lucid32.
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
Then he went to the project directory runit-man, and executed
vagrant init. On the target system, we will need to deploy runit, the runit-man project from the master branch of the source repository and run the runit-man service on port 14500, which must be forwarded to port 14500 of the main operating system for easy testing through the browser.
Any system image prepared for use with Vagrant already includes ruby, and is ready for deployment through Chef, Puppet, or other tools.
The easiest way for me was to use Chef in Solo mode, which does not require installing a Chef server.
Accordingly, he created the cookbooks folder, where he created a collection of provisioning recipes.
Now Vagrantfile has acquired the following form:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid32"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
config.vm.forward_port 14500, 14500
# Enable provisioning with chef solo, specifying a cookbooks path (relative
# to this Vagrantfile), and adding some recipes and/or roles.
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "provisioning"
end
end
To deploy runit, I put a collection of runit recipes (downloaded from GitHub ) in the cookbooks directory .
Accordingly, we need to indicate that the provisioning collection depends on the runit collection (cookbooks / provisioning / metadata.rb):
maintainer "Akzhan Abdulin"
maintainer_email "akzhan.abdulin@gmail.com"
license "MIT License"
description "runit-man development VM"
version "0.1"
depends "runit"
It's time to deploy an empty installation through
vagrant upand start step-by-step describing the provisioning :: default recipe, having previously tried everything in SSH ( vagrant ssh). To do this, we will need to deliver the necessary gems through the Bundler, install Git and deploy the repository and runit-man service (cookbooks / provisioning / recipes / default.rb):
package "git-core"
gem_package "bundler"
git "/home/runit-man" do
repository "git://github.com/Undev/runit-man.git"
end
bash "bundle" do
code "cd /home/runit-man && bundle install --without development"
end
runit_service "runit-man"
The definition of runit_service will automatically install runit and create the runit-man service using the templates we provide.
run-script (cookbooks / provisioning / templates / default / sv-runit-man-run.erb):
#!/bin/bash
exec 2>&1
export PATH="$PATH:/opt/ruby/bin"
exec ruby /home/runit-man/local-run.rb --rackup 'bundle exec rainbows -c rainbows.conf -p 14500'
log-run-script (cookbooks / provisioning / templates / default / sv-runit-man-log-run.erb).
#!/bin/bash
mkdir -p /var/log/runit-man
exec svlogd -tt /var/log/runit-man
This is where the initial deployment of the environment is completed (in my case, I needed an environment to check the runit-man in various boundary cases, development is not conducted in this environment, so packages for development were not installed).
Now you can run
vagrant destroy -f; vagrant upand test the runit-man service (http: // localhost: 14500 /). An additional bonus: the same set of recipe collections can also be used to deploy operating environments.
References: