To avoid the high costs of deploying development and test environments close to the development environment (development stage vs production stage
parity ), virtualization of environments is becoming increasingly popular.
In this article I will tell you how to create an appropriate
replicable development environment using the example of your
runit-man project using
Vagrant .
First we need to install
VirtualBox and Vagrant itself. It is important to note that VirtualBox is highly desirable to install along with guest extensions (Guest Extensions) of the same version, otherwise the deployment will be unstable. Since I am developing for MacOS X, the fact that the corresponding guest extensions for the latest version of VirtualBox are missing is important. So I had to put VirtualBox 4.1.0 together with Vagrant 1.0.1.
')
Then I used the Ubuntu OS image (in principle, I didn’t care what OS to use at this stage) as lucid32.
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
Then I moved 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 start the runit-man service on port 14500, which needs to be forwarded to port 14500 of the main operating system for convenience of testing through a browser.
Any system image prepared for use with Vagrant already includes ruby, and is ready to be deployed via Chef, Puppet, or other tools.
The easiest way for me was to use Chef in Solo mode, which does not require the installation of the Chef server.
Accordingly, I created the cookbooks folder, where I created a collection of recipes provisioning.
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 specify 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 via
vagrant up
and begin step by step to describe the recipe of provisioning :: default, pre-testing everything in SSH (
vagrant ssh
).
To do this, we will need to deliver the necessary gems through the Bundler, install Git and deploy the runit-man repository and 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 a runit-man service using the templates provided by us.
run script (cookbooks / provisioning / templates / default / sv-runit-man-run.erb):
log-run-script (cookbooks / provisioning / templates / default / sv-runit-man-log-run.erb).
At this point, the initial deployment of the environment is complete (in my case, I needed an environment to test the runit-man in various boundary cases, development is not conducted in this environment, so no development packages were installed).
Now you can run
vagrant destroy -f; vagrant up
vagrant destroy -f; vagrant up
and test the runit-man service (http: // localhost: 14500 /).
Extra bonus: the same set of collections of recipes can be used to deploy operating environments.
References: