Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collector attribute and visibility reporting #72

Merged
merged 11 commits into from
Jul 28, 2016
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AllCops:
- Gemfile
- Rakefile
- 'test/**/*'
- 'spec/**/*'
- 'vendor/**/*'
Documentation:
Enabled: false
Expand Down
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

88 changes: 62 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,60 @@ You can see all publicly available InSpec versions [here](https://rubygems.org/g

## Overview

The `audit` support two scenarios:
The `audit` support three scenarios:

### Chef Server Integration

The first scenario requires at least **Chef Compliance 1.0** and the **[Chef Server extensions for Compliance](https://docs.chef.io/integrate_compliance_chef_server.html)**. The architecture looks as following:

```
┌──────────────────────┐ ┌──────────────────────┐ ┌─────────────────────
│ Chef Client │ │ Chef Server │ │ Chef Compliance
│ │ │ │ │
│ ┌──────────────────┐ │ │ │ │
│ │ │◀┼────┼──────────────────────┼────│ Profiles
│ │ audit cookbook │ │ │ │ │
│ │ │─┼────┼──────────────────────┼───▶│ Reports
│ └──────────────────┘ │ │ │ │
│ │ │ │ │
└──────────────────────┘ └──────────────────────┘ └─────────────────────
┌──────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ Chef Client │ │ Chef Server │ │ Chef Compliance │
│ │ │ │ │ │
│ ┌──────────────────┐ │ │ │ │ │
│ │ │◀┼────┼──────────────────────┼────│ Profiles │
│ │ audit cookbook │ │ │ │ │ │
│ │ │─┼────┼──────────────────────┼───▶│ Reports │
│ └──────────────────┘ │ │ │ │ │
│ │ │ │ │ │
└──────────────────────┘ └──────────────────────┘ └─────────────────────┘
```

### Chef Compliance
### Chef Compliance Integration

The second scenario support a direct connection with Chef Compliance and support chef-solo mode as well.
The second scenario supports a direct connection with Chef Compliance. It also supports chef-solo mode.

```
┌──────────────────────┐ ┌─────────────────────
│ Chef Client │ │ Chef Compliance
│ │ │
│ ┌──────────────────┐ │ │
│ │ │◀┼────────────────────────────────│ Profiles
│ │ audit cookbook │ │ │
│ │ │─┼───────────────────────────────▶│ Reports
│ └──────────────────┘ │ │
│ │ │
└──────────────────────┘ └─────────────────────
┌──────────────────────┐ ┌─────────────────────┐
│ Chef Client │ │ Chef Compliance │
│ │ │ │
│ ┌──────────────────┐ │ │ │
│ │ │◀┼────────────────────────────────│ Profiles │
│ │ audit cookbook │ │ │ │
│ │ │─┼───────────────────────────────▶│ Reports │
│ └──────────────────┘ │ │ │
│ │ │ │
└──────────────────────┘ └─────────────────────┘
```

### Chef Visibility Integration

The third scenario supports direct reporting to Chef Visibility. It also supports chef-solo mode.

```
┌──────────────────────┐ ┌─────────────────────┐
│ Chef Client │ ┌───────────────────────┐ │ Chef Visibility │
│ │ ┌──│ Profiles(Supermarket, │ │ │
│ ┌──────────────────┐ │ │ │ Github, local, etc) │ │ │
│ │ │◀┼──┘ └───────────────────────┘ │ │
│ │ audit cookbook │ │ │ │
│ │ │─┼───────────────────────────────▶│ Reports │
│ └──────────────────┘ │ │ │
│ │ │ │
└──────────────────────┘ └─────────────────────┘
```


## Usage

The audit cookbook needs to be configured for each node where the `chef-client` runs. The `audit` cookbook can be reused for all nodes, all node-specific configuration is done via Chef attributes.
Expand Down Expand Up @@ -124,15 +142,15 @@ default['audit'] = {

#### Direct reporting to Chef Compliance

If you want the audit cookbook directly report to Chef Compliance, set the `server` and the `token` attribute.
If you want the audit cookbook to directly report to Chef Compliance, set the `collector`, `server` and the `token` attribute.

* `collector` - 'chef-compliance' to report to Chef Compliance
* `server` - url of Chef Compliance server with `/api`
* `token` - access token for Chef Compliance API (https://github.com/chef/inspec/issues/690)

If those attributes are missing, the audit cookbook expects the Chef Server integration to be available.

```ruby
audit: {
collector: 'chef-compliance',
server: 'https://compliance-fqdn/api/',
token: 'eyJ........................YQ',
profiles: {
Expand All @@ -145,6 +163,7 @@ It is also possible to use a `refresh_token` instead of an access token:

```ruby
audit: {
collector: 'chef-compliance',
server: 'https://compliance-fqdn/api/',
refresh_token: '5/4T...g==',
profiles: {
Expand All @@ -153,6 +172,23 @@ audit: {
}
```


#### Direct reporting to Chef Visibility

If you want the audit cookbook to directly report to Chef Visibility, set the `collector` attribute to 'chef-visibility'.
This method is sending the report to `data_collector.server_url`, defined in `client.rb`. It require `inspec` version `0.27.1` or greater.

```ruby
audit: {
collector: 'chef-visibility',
profiles: {
'brewinc/tmp_compliance_profile' => {
'source' => 'https://github.com/nathenharvey/tmp_compliance_profile'
}
}
}
```

## Relationship with Chef Audit Mode

The following tables compares the [Chef Client audit mode](https://docs.chef.io/ctl_chef_client.html#run-in-audit-mode) with this `audit` cookbook.
Expand Down
9 changes: 8 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
# limitations under the License.
#

# collector possible values: chef-server, chef-compliance, chef-visibility
# chef-visibility requires inspec version 0.27.1 or above
default['audit']['collector'] = 'chef-server'
# server needed for the 'chef-compliance' and 'chef-server' collectors
default['audit']['server'] = nil
# token needed for the 'chef-compliance' collector
default['audit']['token'] = nil
# refresh_token needed for the 'chef-compliance' collector
default['audit']['refresh_token'] = nil
# owner needed for the 'chef-compliance' and 'chef-server' collectors
default['audit']['owner'] = nil
default['audit']['quiet'] = nil
default['audit']['profiles'] = {}
Expand All @@ -34,7 +41,7 @@
default['audit']['fail_if_any_audits_failed'] = false

# inspec gem version to install(e.g. '0.22.1') or 'latest'
default['audit']['inspec_version'] = '0.22.1'
default['audit']['inspec_version'] = '0.27.1'

# by default run audit every time
default['audit']['interval']['enabled'] = false
Expand Down
Loading