0
votes

I am trying to run chef-client in audit mode, using the control_group DSL, as explained here, http://docs.chef.io/analytics/dsl_recipe.html The following is the result I get from running chef-client in local-mode.

[vagrant@centos6 ~]$ sudo chef-client --audit-mode audit-only -z -o audit_centos -c client.rb
[2015-03-01T17:44:10-06:00] INFO: Started chef-zero at http://localhost:8889 with repository at /opt/chef, /root
  One version per cookbook
  environments at /var/chef/environments

[2015-03-01T17:44:10-06:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.0.3
[2015-03-01T17:44:10-06:00] INFO: *** Chef 12.0.3 ***
[2015-03-01T17:44:10-06:00] INFO: Chef-client pid: 4192
[2015-03-01T17:44:16-06:00] WARN: Run List override has been provided.
[2015-03-01T17:44:16-06:00] WARN: Original Run List: []
[2015-03-01T17:44:16-06:00] WARN: Overridden Run List: [recipe[audit_centos]]
[2015-03-01T17:44:16-06:00] INFO: Run List is [recipe[audit_centos]]
[2015-03-01T17:44:16-06:00] INFO: Run List expands to [audit_centos]
[2015-03-01T17:44:16-06:00] INFO: Starting Chef Run for centos6
[2015-03-01T17:44:16-06:00] INFO: Running start handlers
[2015-03-01T17:44:16-06:00] INFO: Start handlers complete.
[2015-03-01T17:44:16-06:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/centos6/runs
resolving cookbooks for run list: ["audit_centos"]
[2015-03-01T17:44:16-06:00] INFO: Loading cookbooks [[email protected]]
[2015-03-01T17:44:16-06:00] INFO: Skipping removal of obsoleted cookbooks from the cache
Synchronizing Cookbooks:
  - audit_centos
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/audit_centos/recipes/default.rb
================================================================================

NoMethodError
-------------
No resource or method named `control_group' for `Chef::Recipe "default"'

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/audit_centos/recipes/default.rb:8:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/audit_centos/recipes/default.rb:

  1:  #
  2:  # Cookbook Name:: audit_centos
  3:  # Recipe:: default
  4:  #
  5:  # Copyright (c) 2015 The Authors, All Rights Reserved.
  6:
  7:  # Check for the latest OpenSSL
  8>> control_group "Check OpenSSL" do
  9:        control "openssl" do
 10:           it "should be installed" do
 11:               expect(package("openssl")).to be_installed.with_version("1.0.1.e-30")
 12:           end
 13:       end
 14:  end
 15:
 16:  # Check for the fstab file
 17:  control_group "Check the FSTab" do


Running handlers:
[2015-03-01T17:44:16-06:00] ERROR: Running exception handlers
Running handlers complete
[2015-03-01T17:44:16-06:00] ERROR: Exception handlers complete
[2015-03-01T17:44:16-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 6.719398287 seconds
[2015-03-01T17:44:16-06:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'
[2015-03-01T17:44:18-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I'm not exactly sure what I'm missing, or doing wrong. This is a stand alone chef-client install, and its not reporting to a chef-server. I have an issue open on my git repository for this as well. https://github.com/predatorian3/audit_centos/issues/1 Are there any example cookbooks, or more explanation on how to use these methods in a cookbook?

2

2 Answers

1
votes

You need the latest ChefDK release candidate (0.5.0) and the latest chef-client. Then you can kitchen converge or knife bootstrap the node.

.kitchen.yml should have

driver_config:
  require_chef_omnibus: latest

Chef Audit Mode Intro

0
votes

Turns out that as of right now, Chef Analytics is a Premium Feature, meaning that you need Enterprise Chef, or pay for remote hosting. Open Source Chef is not supported for this as of right now. Bummer.