2018-02-13 20:27:42 +00:00
---
2019-04-26 18:24:29 +00:00
title: Chef InSpec Reporters
2018-02-13 20:27:42 +00:00
---
2019-04-26 18:24:29 +00:00
# Chef InSpec Reporters
2018-02-13 20:27:42 +00:00
2019-04-26 18:24:29 +00:00
Introduced in Chef InSpec 1.51.6
2018-02-13 20:27:42 +00:00
2019-11-01 21:12:33 +00:00
A `reporter` is a facility for formatting and delivering the results of a Chef InSpec auditing run.
2019-02-22 13:20:05 +00:00
2019-04-26 18:24:29 +00:00
Chef InSpec allows you to output your test results to one or more reporters. Configure the reporter(s) using either the `--reporter` option or as part of the general config file using the `--config` (or `--json-config` , prior to v3.6) option. While you can configure multiple reporters to write to different files, only one reporter can output to the screen(stdout).
2018-02-13 20:27:42 +00:00
## Syntax
2018-03-20 12:43:30 +00:00
You can specify one or more reporters using the `--reporter` cli flag. You can also specify a output by appending a path separated by a colon.
2018-02-13 20:27:42 +00:00
Output json to screen.
```bash
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter json
2019-02-22 13:20:05 +00:00
# or explicitly specifying output to STDOUT:
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter json:-
2018-02-13 20:27:42 +00:00
```
2018-05-31 17:42:09 +00:00
Output yaml to screen
```bash
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter yaml
2019-02-22 13:20:05 +00:00
# or
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter yaml:-
2018-05-31 17:42:09 +00:00
```
2018-02-13 20:27:42 +00:00
Output cli to screen and write json to a file.
```bash
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter cli json:/tmp/output.json
2018-02-13 20:27:42 +00:00
```
Output nothing to screen and write junit and html to a file.
```bash
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter junit:/tmp/junit.xml html:www/index.html
2018-02-13 20:27:42 +00:00
```
Output json to screen and write to a file. Write junit to a file.
```bash
2018-10-30 10:32:16 +00:00
inspec exec example_profile --reporter json junit:/tmp/junit.xml | tee out.json
```
If you wish to pass the profiles directly after specifying the reporters you will need to use the end of options flag `--` .
```bash
inspec exec --reporter json junit:/tmp/junit.xml -- profile1 profile2
2018-02-13 20:27:42 +00:00
```
2019-02-14 21:04:06 +00:00
If you are using the cli option `--config` , you can also set reporters.
2018-02-13 20:27:42 +00:00
Output cli to screen.
```json
{
"reporter": {
"cli" : {
"stdout" : true
}
}
}
```
Output cli to screen and write json to a file.
```json
{
"reporter": {
"cli" : {
"stdout" : true
},
"json" : {
"file" : "/tmp/output.json",
"stdout" : false
}
}
}
```
## Supported Reporters
The following are the current supported reporters:
### cli
This is the basic text base report. It includes details about which tests passed and failed and includes an overall summary at the end.
### json
This reporter includes all information about the profiles and test results in standard json format.
### json-min
This reporter is a redacted version of the json and only includes test results.
2018-05-31 17:42:09 +00:00
### yaml
This reporter includes all information about the profiles and test results in standard yaml format.
2018-02-13 20:27:42 +00:00
### documentation
This reporter is a very minimal text base report. It shows you which tests passed by name and has a small summary at the end.
### junit
This reporter outputs the standard junit spec in xml format.
### progress
This reporter is very condensed and gives you a `.` (pass), `f` (fail), or `*` (skip) character per test and a small summary at the end.
### json-rspec
This reporter includes all information from the rspec runner. Unlike the json reporter this includes rspec specific details.
### html
This renders html code to view your tests in a browser. It includes all the test and summary information.
2018-06-14 18:05:21 +00:00
## Automate Reporter
2019-02-22 13:20:05 +00:00
The `automate` reporter type is a special reporter used with [Chef Automate ](https://automate.chef.io/ ). To use this reporter you must pass in the correct configuration via a json config `--config` .
2018-06-14 18:05:21 +00:00
Example config:
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
```json
"reporter": {
"automate" : {
"stdout" : false,
"url" : "https://YOUR_A2_URL/data-collector/v0/",
"token" : "YOUR_A2_ADMIN_TOKEN",
"insecure" : true,
"node_name" : "inspec_test_node",
"environment" : "prod"
}
}
```
2018-07-19 18:31:38 +00:00
### Mandatory fields
2018-06-14 18:05:21 +00:00
#### stdout
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
This will either suppress or show the automate report in the CLI screen on completion
#### url
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
This is your Automate 2 url. Append `data-collector/v0/` at the end.
#### token
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
This is your Automate 2 token. You can generate this token by navigating to the admin tab of A2 and then api keys.
### Optional fields
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
#### insecure
2018-07-19 18:31:38 +00:00
2018-06-14 18:05:21 +00:00
This will disable or enable the ssl check when accessing the Automate 2 instance.
#### node_name
2018-07-19 18:31:38 +00:00
2018-11-15 18:19:37 +00:00
This will be the node name which shows up in Automate.
2018-06-14 18:05:21 +00:00
#### node_uuid
2018-07-19 18:31:38 +00:00
2018-11-15 18:19:37 +00:00
This will be the node UUID which shows up in Automate. You will want to use a single static UUID per node for all your reports.
2018-06-14 18:05:21 +00:00
#### environment
2018-07-19 18:31:38 +00:00
2018-11-15 18:19:37 +00:00
This will set the environment metadata for Automate.