github.com/kimor79/packer@v0.8.7-0.20151221212622-d507b18eb4cf/website/source/docs/command-line/machine-readable.html.markdown (about) 1 --- 2 description: | 3 By default, the output of Packer is very human-readable. It uses nice 4 formatting, spacing, and colors in order to make Packer a pleasure to use. 5 However, Packer was built with automation in mind. To that end, Packer supports 6 a fully machine-readable output setting, allowing you to use Packer in automated 7 environments. 8 layout: docs 9 page_title: 'Machine-Readable Output - Command-Line' 10 ... 11 12 # Machine-Readable Output 13 14 By default, the output of Packer is very human-readable. It uses nice 15 formatting, spacing, and colors in order to make Packer a pleasure to use. 16 However, Packer was built with automation in mind. To that end, Packer supports 17 a fully machine-readable output setting, allowing you to use Packer in automated 18 environments. 19 20 The machine-readable output format is easy to use and read and was made with 21 Unix tools in mind, so it is awk/sed/grep/etc. friendly. 22 23 ## Enabling 24 25 The machine-readable output format can be enabled by passing the 26 `-machine-readable` flag to any Packer command. This immediately enables all 27 output to become machine-readable on stdout. Logging, if enabled, continues to 28 appear on stderr. An example of the output is shown below: 29 30 ``` {.text} 31 $ packer -machine-readable version 32 1376289459,,version,0.2.4 33 1376289459,,version-prerelease, 34 1376289459,,version-commit,eed6ece 35 1376289459,,ui,say,Packer v0.2.4.dev (eed6ece+CHANGES) 36 ``` 37 38 The format will be covered in more detail later. But as you can see, the output 39 immediately becomes machine-friendly. Try some other commands with the 40 `-machine-readable` flag to see! 41 42 ## Format 43 44 The machine readable format is a line-oriented, comma-delimited text format. 45 This makes it extremely easy to parse using standard Unix tools such as awk or 46 grep in addition to full programming languages like Ruby or Python. 47 48 The format is: 49 50 ``` {.text} 51 timestamp,target,type,data... 52 ``` 53 54 Each component is explained below: 55 56 - **timestamp** is a Unix timestamp in UTC of when the message was printed. 57 58 - **target** is the target of the following output. This is empty if the 59 message is related to Packer globally. Otherwise, this is generally a build 60 name so you can relate output to a specific build while parallel builds 61 are running. 62 63 - **type** is the type of machine-readable message being outputted. There are 64 a set of standard types which are covered later, but each component of 65 Packer (builders, provisioners, etc.) may output their own custom types as 66 well, allowing the machine-readable output to be infinitely flexible. 67 68 - **data** is zero or more comma-seperated values associated with the 69 prior type. The exact amount and meaning of this data is type-dependent, so 70 you must read the documentation associated with the type to 71 understand fully. 72 73 Within the format, if data contains a comma, it is replaced with 74 `%!(PACKER_COMMA)`. This was preferred over an escape character such as `\'` 75 because it is more friendly to tools like awk. 76 77 Newlines within the format are replaced with their respective standard escape 78 sequence. Newlines become a literal `\n` within the output. Carriage returns 79 become a literal `\r`. 80 81 ## Message Types 82 83 The set of machine-readable message types can be found in the [machine-readable 84 format](/docs/machine-readable/index.html) complete documentation section. This 85 section contains documentation on all the message types exposed by Packer core 86 as well as all the components that ship with Packer by default.