» Machine Readable Output

Every Vagrant command accepts a —machine-readable flag which enablesmachine readable output mode. In this mode, the output to the terminalis replaced with machine-friendly output.

This mode makes it easy to programmatically execute Vagrant and read dataout of it. This output format is protected by ourbackwards compatibilitypolicy. Until Vagrant 2.0 is released, however, the machine readable outputmay change as we determine more use cases for it. But the backwardscompatibility promise should make it safe to write client libraries toparse the output format.

Advanced topic! This is an advanced topic for use only ifyou want to programmatically execute Vagrant. If you are just getting startedwith Vagrant, you may safely skip this section.

» Work-In-Progress

The machine-readable output is very new (released as part of Vagrant 1.4).We're still gathering use cases for it and building up the output for eachof the commands. It is likely that what you may want to achieve withthe machine-readable output is not possible due to missing information.

In this case, we ask that you pleaseopen an issuerequesting that certain information become available. We will most likely addit!

» Format

The machine readable format is a line-oriented, comma-delimited text format.This makes it extremely easy to parse using standard Unix tools such as awk orgrep in addition to full programming languages like Ruby or Python.

The format is:

  1. timestamp,target,type,data...

Each component is explained below:

  • timestamp is a Unix timestamp in UTC of when the message was printed.

  • target is the target of the following output. This is empty if themessage is related to Vagrant globally. Otherwise, this is generally a machinename so you can relate output to a specific machine when multi-VM is in use.

  • type is the type of machine-readable message being outputted. There area set of standard types which are covered later.

  • data is zero or more comma-separated values associated with the priortype. The exact amount and meaning of this data is type-dependent, so youmust read the documentation associated with the type to understand fully.

Within the format, if data contains a comma, it is replaced with%!(VAGRANT_COMMA). This was preferred over an escape character such as \'because it is more friendly to tools like awk.

Newlines within the format are replaced with their respective standard escapesequence. Newlines become a literal \n within the output. Carriage returnsbecome a literal \r.

» Types

This section documents all the available types that may be outputtedwith the machine-readable output.

TypeDescription
box-nameName of a box installed into Vagrant.
box-providerProvider for an installed box.
cli-commandA subcommand of vagrant that is available.
error-exitAn error occurred that caused Vagrant to exit. This contains thaterror. Contains two data elements: type of error, error message.
provider-nameThe provider name of the target machine.targeted
ssh-configThe OpenSSH compatible SSH config for a machine. This is usually the result of the "ssh-config" command.targeted
stateThe state ID of the target machine.targeted
state-human-longHuman-readable description of the state of the machine. This is thelong version, and may be a paragraph or longer.targeted
state-human-shortHuman-readable description of the state of the machine. This is theshort version, limited to at most a sentence.targeted