Skip to main content

HashiCorp Vagrant 2.1.0

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.

Download Now

This release of Vagrant includes a handful of bug fixes and improvements. Notable updates in this release include:

  • Updates to the docker, chef, and puppet provisioners
  • Disable automatic exception reports by default
  • Improved Hyper-V enabled check for Windows hosts

»Vagrant Triggers

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!

»New Generic Linux Package

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.

»Other improvements

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.


Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.