I would like to know how Vagrant works

1

I have seen several tutorials on the internet, and several subjects on youtube, but so far I have not understood how it works.

In most of the things I saw, I was teaching to install a virtual machine and run, but after that, I do what? How can this help me with a future project?

    
asked by anonymous 02.09.2015 / 06:30

3 answers

3

The main advantage of Vagrant in my understanding is to allow each developer to use the native resources of their environment during development (eg, text editor, IDE, etc.) but the execution environment ( ) is identical for all of them - and this is identical (as far as possible) to that which will be used in production.

The first step, as you have already noted, is to install and run a virtual machine. But which? Now, the one that is most similar to the environment in which the system will actually run. If it is a client-server architecture, the virtual machine must use the same operating system as the server, have installed the same packages that will be present on the server (and the same version), etc. If it's a cross-platform system, which needs to run in a variety of different environments, then you would create a separate virtual machine for each of them (without having to keep all of them running at the same time, of course).

Once you have defined the virtual machine (s) to be used, and how it will be configured (you can either pre-install a dependency set, or create a startup script for each virtual machine to should be made available to each developer of your team so that everyone works in an identical environment.

The last step is to map a set of folders from the host environment (i.e. your computer) to a set of folders in the host environment (i.e. the virtual machine). This allows you to edit files, model, etc. using your preferred tools (which may differ from those of your colleagues), but when compiling and executing everything is done within the virtual environment. Thus, when running, the differences between computers have their impact minimized, being restricted only to performance (i.e., the ability of the host system to emulate the guest system).

Nothing prevents you from compiling / executing on on your own computer, of course, if it provides a compatible environment. The important thing is that you never make ("check in") files that have been tested only on your machine. Instead, before putting your modifications into version control you should open each virtual machine (if there is only one, best leave it open straight) and test the system on it, to ensure that what works in one environment does not cause bugs in another.

    
02.09.2015 / 07:05
1

Vagrant creates a virtual environment that isolates dependencies and settings in a single environment. Once someone has created a vagrantfile, you just have to run the vagrant up command that everything is set up and installed for you.

You can also use vagrant to test an app on some remote cloud, with exactly the same configuration as your machine.

    
02.09.2015 / 06:54
1

Vagrant helps you have a development environment closer to production. And if - for example - an employee enters your company, just take that box (system image, already configured for every taste and need) with the necessary settings for it . The cost / time to replicate this environment and the tests for your application are better.

If you are using Windows, you will connect to your virtual machine via SSH. PuTTY will help you with this.

I also recommend reading Using Vagrant as an environment for development in Windows

    
02.09.2015 / 07:11