Tech & DevOps HubEspace Tech & DevOps

Explorez le monde du Dev, du Cloud et des outils DevOps à travers nos articles et discussions Explore the world of development, the cloud and DevOps tools
 FR      EN
Vagrant
Général
Stop VM
vagrant halt

Shuts down the VM cleanly.
Start VM
vagrant up

Launch and provision the virtual machine.
Destroy VM
vagrant destroy -f

Permanently deletes the VM without confirmation.
Initialize a Vagrant environment
vagrant init centos/7

Create a Vagrantfile for the CentOS 7 box
List available VM
vagrant global-status

Displays the status and ID of all local VMs.
Pause a VM
vagrant suspend

Allows you to pause the VM by saving its current state, similar to hibernation.
This is the fastest way to temporarily stop working. Restarting the machine with vagrant up will then take only a few seconds, since the system doesn’t need to restart from scratch
Unlike a standard shutdown (vagrant halt), this command writes the entire contents of the virtual machine’s RAM to a file on your hard drive. Use it for short breaks (a few hours), not for long-term use
Provision again
vagrant provision

Applies changes to configuration scripts without restarting the VM
It avoids the full reboot cycle (vagrant reload) or rebuild cycle (vagrant destroy + vagrant up)
If the Vagrantfile contains multiple steps, you can execute just one of them: e.g.: vagrant provision --provision-with ansible
Do everything at once on startup: vagrant up --provision
Reload configuration without destroy
vagrant reload

Allows you to restart a VM while applying the latest changes made to the Vagrantfile without deleting the VM. This is the ideal command when network file shares or private IP addresses become unresponsive after the host computer goes to sleep
By default, the command does not run configuration scripts (Ansible, Shell). To force software reconfiguration immediately after restarting, add the --provision option
Resume a suspended VM
vagrant resume

Picks up the VM from where it was suspended
If the machine is powered off or has not been created, you must use vagrant up
If your machine is suspended (saved), you can use vagrant up OR vagrant resume
Connect via SSH
vagrant ssh

Open a shell session on the VM.
Box
Export a box
vagrant package --output mybox.box

Create a complete portable archive of a VM on https://developer.hashicorp.com/vagrant/vagrant-cloud
Update Vagrant box
vagrant box update

Download the latest versions of the boxes
Check box config
vagrant box list

List all locally installed boxes.
Plugin
Add plugin
vagrant plugin install vagrant-hostmanager

Installs the "vagrant-hostmanager" plugin that allows you to access virtual machines using a domain name (e.g., api.local) instead of an IP address.
It securely modifies the /etc/hosts file or its Windows equivalent when the VM starts up.
Example configuration in the Vagrantfile config.hostmanager.enabled = true config.hostmanager.manage_host = trueTo check a plugin, its technical specifications, download statistics, or activity, simply search by keyword on the official RubyGems
To avoid installing outdated packages, the community maintains up-to-date, curated lists. The current reference is the collaborative Vagrant-Lists repository on GitHub
List the installed plugins and their versions
vagrant plugin list

Displays all active plugins on the machine. This allows you to check versions or identify outdated plugins that need to be uninstalled.
Related commands
Uninstall: vagrant plugin uninstall
Update: vagrant plugin update