github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/website/source/docs/command-line/machine-readable.html.md (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 ~> `-machine-readable` is designed for automated environments and is mutually-exclusive with the `-debug` flag, which is designed for interactive environments. 43 44 ## Format 45 46 The machine readable format is a line-oriented, comma-delimited text format. 47 This makes it extremely easy to parse using standard Unix tools such as awk or 48 grep in addition to full programming languages like Ruby or Python. 49 50 The format is: 51 52 ``` {.text} 53 timestamp,target,type,data... 54 ``` 55 56 Each component is explained below: 57 58 - **timestamp** is a Unix timestamp in UTC of when the message was printed. 59 60 - **target** is the target of the following output. This is empty if the 61 message is related to Packer globally. Otherwise, this is generally a build 62 name so you can relate output to a specific build while parallel builds 63 are running. 64 65 - **type** is the type of machine-readable message being outputted. There are 66 a set of standard types which are covered later, but each component of 67 Packer (builders, provisioners, etc.) may output their own custom types as 68 well, allowing the machine-readable output to be infinitely flexible. 69 70 - **data** is zero or more comma-seperated values associated with the 71 prior type. The exact amount and meaning of this data is type-dependent, so 72 you must read the documentation associated with the type to 73 understand fully. 74 75 Within the format, if data contains a comma, it is replaced with 76 `%!(PACKER_COMMA)`. This was preferred over an escape character such as `\'` 77 because it is more friendly to tools like awk. 78 79 Newlines within the format are replaced with their respective standard escape 80 sequence. Newlines become a literal `\n` within the output. Carriage returns 81 become a literal `\r`. 82 83 ## Message Types 84 85 The set of machine-readable message types can be found in the [machine-readable 86 format](/docs/machine-readable/index.html) complete documentation section. This 87 section contains documentation on all the message types exposed by Packer core 88 as well as all the components that ship with Packer by default.