In my opinion, most IT professionals should use
Vagrant . Who does not know what it is - I recommend to start from the official site. On Habré, there were also several reviews of the vagrant, for example,
Development Environment using Vagrant and Chef and
Creating a new virtual machine in one minute or “vagrant up!” . In this article I will talk in more detail about the "ecosystem" of a vagrant.
If you try to describe the vagrant in a few words, it is a tool for the repeated creation of the environment with the help of your favorite configuration management system and your favorite virtualization system. And if there are quite a lot of virtualization systems and configuration management systems, the vagrant is the only product of its kind, it has no analogues.
But consider the situation in more detail. At the moment, the vagrant supports the
following virtualization systems right out of the box:
- VirtualBox - it was from his support that the vagand began.
- VMware - it needs a paid plugin.
- AWS - you can make your virtual machines immediately in the Amazon cloud.
In addition, third-party developers have written the following plugins (here, of course, not all are listed):
')
- Vagrant-lxc - plugin for container virtualization system. LXC , a little damp, but actively developed.
- Vagrant-libvirt - promises to support all the virtualization systems that libvirt supports, and there are about a dozen of them.
- Vagrant-kvm - plugin for KVM virtualization system.
- Vagrant-parallels - plugin for Parallels virtualization system. It turns out that under Parallels you can run not only Windows on a Mac, but also develop the infrastructure, moreover, employees from our company Express 42 successfully do it. The plugin is developed by the Parallels company itself, and it is actively developing.
Just in case our box for Parallels with Ubuntu 12.04 lies
here .
Using various virtualization systems, a vagent can be an indispensable tool that tests various aspects of your infrastructure with the help of tests in a CI environment.
After you have connected your virtualization system, you need to decide on the configuration management system. The following
systems are currently supported (provisioning):
- Shell - good old shell scripts. In the XXI century is no longer interesting.
- Ansible is a young, gaining momentum, configuration management system.
- Chef - about him, perhaps, everyone heard. Standalone (Chef Solo) and server (Chef Client) versions are supported.
- Docker is a recently fashionable system that supports the concept of Immutable Server (we talked about it in the latest release of the Devops Deflope podcast).
- Puppet is one of the most common configuration management systems. It supports standalone and server version.
- Salt - Salt Stack configuration management system.
Then everything is extremely simple - you need a "reference" image of the operating system. You can do it yourself, it's not so difficult, but you can take it ready, for example, on the website
VagrantBox.es . Our box for VirtualBox with Ubuntu 12.04 is
here .
If you still do not like ready-made solutions, then there are projects that allow you to automate the creation of basic images. For example,
VeeWee (
introductory article about it on Habré ) and
Packer . The latter is made by Mitchell Hashimoto, the author of the vagrant. Unfortunately, there are no Russian-language reviews, but we will definitely write about it in one of the upcoming articles.
It is important to note that the reference OS image makes sense to use the same for all your environments - from developer to combat.
After that, you collect everything together using Vagrantfile. For example, I give a configuration file that allows you to run several machines at once, which is very useful if you need to test some distributed environment.
Vagrant.configure("2") do |config| config.vm.define :infra do |main| main.vm.box = "ubuntu12.04-chef11" main.vm.hostname = "infra" config.vm.network :forwarde_port, guest: 80, host: 8002 config.vm.network :private_network, ip: "192.168.100.13" main.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] end config.vm.provision :chef_solo do |chef| chef.log_level = :info chef.roles_path = "roles" chef.data_bags_path = "data_bags" chef.add_role "base" chef.add_role "zabbix-db" chef.add_role "zabbix-server" chef.add_role "graylog2" end end config.vm.define :vm1 do |main| main.vm.box = "ubuntu12.04-chef11" main.vm.hostname = "vm1" config.vm.network :forwarded_port, guest: 80, host: 8001 config.vm.network :private_network, ip: "192.168.100.14" main.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] end config.vm.provision :chef_solo do |chef| chef.log_level = :info chef.roles_path = "roles" chef.data_bags_path = "data_bags" chef.add_role "base" chef.add_role "zabbix-client" chef.add_role "projectname" end end end
With a similar configuration file, you can raise virtual machines separately, for example,
vagrant up infra
or
vagrant up vm1
.
Here the article could be completed, but, among other things, there are many plug-ins for the vagrant that extend and complement its functionality.
A list of the most well-known plug-ins is available on the Vagor wiki Here are the most interesting of them, in my opinion.
- Vagrant-cachier - caches requests to repositories of various package managers (deb, rpm), which allows you to pick up machines much faster.
- Vagrant-librarian-chef - the integration of the vagrant and librarian-chef . You can read more about why librarian-chef is needed in our article .
- Vagrant-berkshelf - integration of the vagrant and Berkshelf (similar to librarian-chef).
- Sahara - this plugin allows you to "cut" your virtual machine so that you can easily roll back.
Vagrant helps in a repetitive way to prepare the environment of your projects. Vagrant allows you to start integration from the earliest stage - from the development stage. I am deeply convinced that this is the only way to “prepare” the infrastructure. But now, few people cook like that. And “Express 42” is preparing this way.