Skip to content

mrlucasfreitas/easy-vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Logo of the project

Easy Vagrant

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.

Why use Vagrant?

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.

Install Vagrant

Use the commands to install in MAC or Linux.

Fisrt

Install VirtualBox from official site.

MacOS

After installing homebrew.

$ brew cask install vagrant
$ brew cask install vagrant-manager
$ vagrant --help

Linux

$ apt update
$ apt install vagrant

Install Vagrant-hostsupdater

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.

Basic commands

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

Vagrantfile examples

Some examples of Vagrantfile that can be used:

  • Basic

    A basic configuration for starting a Vagrantfile.

  • Advanced

    A more complete Vagrantfile configuration, containing array and loops.

  • Ansible

    Automatically provisioning a Vagrant machine in an Ansible role.

  • Execute scripts

    Run SH scripts on a Vagrantfile.

  • Kubernetes

    Use for Kubernetes Cluster tests, you need good settings.

  • My Vagrant

    My daily use, a mix of all the examples above.

Additional informations

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.

About

Vagrant - Easy, simple and functional

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published