Always in branch Master.
Welcome to my fast project about vagrant, easy, simple and functional.
My objective is to show vagrant for daily use in uncomplicated, simple and useful ways.
Use mainly to learn, test and develop environments, because Vagrant is a manipulator of virtual machines that can be created, modified and destroyed with just one command (after configuring Vagrantfile).
In particular, I use it for software testing, application deployment and my favorite, creating ansible roles.
Use the commands to install in MAC or Linux.
Install VirtualBox from official site.
After installing homebrew.
$ brew cask install vagrant
$ brew cask install vagrant-manager
$ vagrant --help
$ apt update
$ apt install vagrant
This plugin adds an entry to your /etc/hosts file on the host system.
Install plugin:
$ vagrant plugin install vagrant-hostsupdater
Update the plugin with:
$ vagrant plugin update vagrant-hostsupdater
Enable host resolution defined in Vagrantfile:
Example in Vagrantfile:
...
config.vm.hostname = "vagrant-test.local"
...
Test:
$ ping vagrant-test.local
More information here.
Now create a test directory and cd into the test directory. Initialize the vagrant machine.
$ vagrant init precise64
Start the machine.
$ vagrant up
Show machine status.
$ vagrant status
You can ssh into the machine.
$ vagrant ssh
Reload the vagrant machine.
$ vagrant reload
Suspend the vagrant machine.
$ vagrant suspend
Active the machine that was suspended.
$ vagrant resume
Halt the vagrant machine.
$ vagrant halt
Destroy the vagrant machine.
$ vagrant destroy
Some examples of Vagrantfile that can be used:
-
A basic configuration for starting a Vagrantfile.
-
A more complete Vagrantfile configuration, containing array and loops.
-
Automatically provisioning a Vagrant machine in an Ansible role.
-
Run SH scripts on a Vagrantfile.
-
Use for Kubernetes Cluster tests, you need good settings.
-
My daily use, a mix of all the examples above.
In this project, I used Bento's images, but feel free to change.
OS used:
- Ubuntu 18
- CentOS 6
- CentOS 7
- CentOS 8
- FreeBSD 12
Other images and versions available: Vagrant Cloud.