We are pleased to announce the release of Vagrant 2.1.0. Vagrant is a tool for building and distributing development environments. The highlight of this release is the introduction of Vagrant triggers as a core feature.
This release of Vagrant includes a handful of bug fixes and improvements. Notable updates in this release include:
With this release, Vagrant is now capable of executing machine triggers before or after certain Vagrant commands. Each trigger is expected to be given a command key for when it should be fired during the Vagrant command lifecycle.
This work was heavily inspired by the fantastic community plugin vagrant-triggers by @emyl. It is a complete rewrite of the plugin, so the two are not compatible. Vagrant will disable the core trigger functionality if it detects the community vagrant-triggers plugin. This allows users to continue to use the plugin if they wish.
The following is a basic example of two global triggers. One that runs before
the :up
command and one that runs after the :up
command:
Vagrant.configure("2") do |config|
config.trigger.before :up do |trigger|
trigger.name = "Hello world"
trigger.info = "I am running before vagrant up!!"
end
config.trigger.after :up do |trigger|
trigger.name = "Hello world"
trigger.info = "I am running after vagrant up!!"
end
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.box = "ubuntu"
end
end
These will run before and after each defined guest in the Vagrantfile.
Running a remote script to save a database on your host before __destroy__ing a guest:
Vagrant.configure("2") do |config|
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.box = "ubuntu"
ubuntu.trigger.before :destroy do |trigger|
trigger.warn = "Dumping database to /vagrant/outfile"
trigger.run_remote = {inline: "pg_dump dbname > /vagrant/outfile"}
end
end
end
Now that the trigger is defined, running the destroy command will fire off the defined trigger before Vagrant destroys the machine.
If you’d like to know more about the feature, check out the documentation for more information!
The Vagrant 2.1.0 release includes the initial offering of a generic Linux package for Vagrant. This package includes a single Vagrant executable file which users can install into a directory on their PATH. The Vagrant executable in this package is an AppImage application and is intended for distributions where a native Vagrant package may not available.
The Vagrant 2.1.0 release also includes a number of other improvements and bug fixes. For a detailed list of all the changes in this release, see the CHANGELOG.
Before we ring in the new year, here’s a look back at some of the most important moments in 2022 for HashiCorp.
HashiCorp Vagrant 2.3 introduces a new Vagrant executable written in Golang, tying the Vagrant architecture more closely into the broader HashiCorp ecosystem.
The HashiCorp Releases API is now available. This API is your one-stop shop for finding and viewing extended metadata about HashiCorp product releases.