Vagrant

A Vagrant CLI wrapper for Elixir.

Installation

If available in Hex, the package can be installed as:

  1. Add vagrant to your list of dependencies in mix.exs:

    def deps do

     [{:vagrant, "~> 0.0.1"}]

    end

  2. Ensure vagrant is started before your application:

    def application do

     [applications: [:vagrant]]

    end

Usage

Vagrant generally wraps the CLI for the vagrant command. For example, you can call vagrant up

Vagrant.up

By default, all commands will look for the Vagrant file by traversing the previous dir until the first one it finds. Alternatively, you can pass options to point it to the right vagrant file.

Vagrant.up vagrantfile: "test/support/Vagrantfile"

There may also be times when you want to pass the output of the underlying vagrant commands to an alternative output, like :stdio. You can also pass any flags to the command using flags: []

Vagrant.up out: :stdio, flags: ["--debug"]

Commands are expected to return {:ok | :error, result} All return types are attempted to be parsed using the Vagrant Machine Readable format. Additionally, certain modules have enhanced structs for representing the machine readable data like Vagrant.Message.Status

Vagrant.status
%Vagrant.Message.Status{state_long: "running", state: :running, provider: "virtualbox"}

Commands

Vagrant.up
Vagrant.halt
Vagrant.reload
Vagrant.status