📜 ⬆️ ⬇️

About Vagrant, its plugins, and other life stories of vagrants

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:


In addition, third-party developers have written the following plugins (here, of course, not all are listed):
')

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):


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 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.

Source: https://habr.com/ru/post/206768/


All Articles