Issues running Test Kitchen in Audit mode


#1

Hello all,

I’m attempting to use test kitchen with chef-audit to test some of my audits but running into the following error:

   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'

See below for debug info. This runs fine on the actual server but via test kitchen fails with the above message… any ideas?

Application Versions

Test Kitchen: 1.4.0
Chef-Client: 12.3.0
Chefdk: 0.6.2 Release: 1.el6

Kitchen YML File


driver:
name: ssh
hostname: <%= ENV[‘vagrant_ip’] %>
port: '22’
username: username
password: xxxxxxxx

provisioner:
name: chef_zero
client_rb:
audit_mode: :audit_only
platforms:

  • name: rhel-6.3

suites:

  • name: default
    run_list:
    • recipe[test-audit::default]
      attributes:

default.rb Recipe/Audit

Cookbook Name:: test-audit

Recipe:: default

Copyright © 2015 The Authors, All Rights Reserved.

control_group ‘Blog Post Examples’ do
control ‘SSH’ do
it ‘should be listening on port 22’ do
expect(port(22)).to be_listening
end
end
end

Trace from Test Kitchen

-----> Starting Kitchen (v1.4.0)
-----> Cleaning up any prior instances of
-----> Destroying …
Kitchen-ssh does not destroy your server ‘’ by shutting it down…
Shutdown your server ‘’ natively with user ''
in your cloud or virtualisation console etc.\n
Finished destroying (0m0.00s).
-----> Testing
-----> Creating …
Kitchen-ssh does not start your server ‘10.126.69.72’ but will look for an ssh connection with user ‘vagrant’
[SSH] Established
Kitchen-ssh found ssh ready on host ‘10.126.69.72’ with user ‘vagrant’

   Finished creating <default-rhel-63> (0m1.21s).

-----> Converging …
$$$$$$ Running legacy converge for ‘Ssh’ Driver
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 3.3.0…
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to
Starting Chef Client, version 12.0.3
[2015-09-08T13:42:37-04:00] WARN: Child with name ‘dna.json’ found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
resolving cookbooks for run list: [“test-audit::default”]
Synchronizing Cookbooks:
- test-audit
Compiling Cookbooks…

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb
   ================================================================================

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

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:7:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:

     1:  #
     2:  # Cookbook Name:: test-audit
     3:  # Recipe:: default
     4:  #
     5:  # Copyright (c) 2015 The Authors, All Rights Reserved.
     6:
     7>> control_group 'Blog Post Examples' do
     8:    control 'SSH' do
     9:      it 'should be listening on port 22' do
    10:        expect(port(22)).to be_listening
    11:      end
    12:    end
    13:  end
    14:


   Running handlers:
   [2015-09-08T13:42:37-04:00] ERROR: Running exception handlers
   Running handlers complete
   [2015-09-08T13:42:37-04:00] ERROR: Exception handlers complete
   [2015-09-08T13:42:37-04:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   Chef Client failed. 0 resources updated in 8.00419466 seconds
   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'
   [2015-09-08T13:42:39-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Converge failed on instance .
Please see .kitchen/logs/default-rhel-63.log for more details
------Exception-------
Class: Kitchen::ActionFailed
Message: SSH exited (1) for command: [sh -c ’

sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
’]


Thanks,
Anushan Rajakulasingam


#2

The output indicates you’re running Chef Client 12.0.3 not 12.3.0.
Audit mode was added in 12.1.0.

  • Julian

On Tue, Sep 8, 2015 at 1:58 PM, Rajakulasingam, Anushan
Anushan.Rajakulasingam@cibc.com wrote:

Hello all,

I’m attempting to use test kitchen with chef-audit to test some of my audits but running into the following error:

   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'

See below for debug info. This runs fine on the actual server but via test kitchen fails with the above message… any ideas?

Application Versions

Test Kitchen: 1.4.0
Chef-Client: 12.3.0
Chefdk: 0.6.2 Release: 1.el6

Kitchen YML File


driver:
name: ssh
hostname: <%= ENV[‘vagrant_ip’] %>
port: '22’
username: username
password: xxxxxxxx

provisioner:
name: chef_zero
client_rb:
audit_mode: :audit_only
platforms:

  • name: rhel-6.3

suites:

  • name: default
    run_list:
    • recipe[test-audit::default]
      attributes:

default.rb Recipe/Audit

Cookbook Name:: test-audit

Recipe:: default

Copyright © 2015 The Authors, All Rights Reserved.

control_group ‘Blog Post Examples’ do
control ‘SSH’ do
it ‘should be listening on port 22’ do
expect(port(22)).to be_listening
end
end
end

Trace from Test Kitchen

-----> Starting Kitchen (v1.4.0)
-----> Cleaning up any prior instances of
-----> Destroying …
Kitchen-ssh does not destroy your server ‘’ by shutting it down…
Shutdown your server ‘’ natively with user ''
in your cloud or virtualisation console etc.\n
Finished destroying (0m0.00s).
-----> Testing
-----> Creating …
Kitchen-ssh does not start your server ‘10.126.69.72’ but will look for an ssh connection with user ‘vagrant’
[SSH] Established
Kitchen-ssh found ssh ready on host ‘10.126.69.72’ with user ‘vagrant’

   Finished creating <default-rhel-63> (0m1.21s).

-----> Converging …
$$$$$$ Running legacy converge for ‘Ssh’ Driver
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 3.3.0…
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to
Starting Chef Client, version 12.0.3
[2015-09-08T13:42:37-04:00] WARN: Child with name ‘dna.json’ found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
resolving cookbooks for run list: [“test-audit::default”]
Synchronizing Cookbooks:
- test-audit
Compiling Cookbooks…

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb
   ================================================================================

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

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:7:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:

     1:  #
     2:  # Cookbook Name:: test-audit
     3:  # Recipe:: default
     4:  #
     5:  # Copyright (c) 2015 The Authors, All Rights Reserved.
     6:
     7>> control_group 'Blog Post Examples' do
     8:    control 'SSH' do
     9:      it 'should be listening on port 22' do
    10:        expect(port(22)).to be_listening
    11:      end
    12:    end
    13:  end
    14:


   Running handlers:
   [2015-09-08T13:42:37-04:00] ERROR: Running exception handlers
   Running handlers complete
   [2015-09-08T13:42:37-04:00] ERROR: Exception handlers complete
   [2015-09-08T13:42:37-04:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   Chef Client failed. 0 resources updated in 8.00419466 seconds
   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'
   [2015-09-08T13:42:39-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Converge failed on instance .
Please see .kitchen/logs/default-rhel-63.log for more details
------Exception-------
Class: Kitchen::ActionFailed
Message: SSH exited (1) for command: [sh -c ’

sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
’]


Thanks,
Anushan Rajakulasingam


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]


#3

Interesting…

On console if I type chef-client -version
It spits out:
Chef: 12.3.0

But the running client itself is reporting 12.0.3 in the output… is this a bug?

Thanks,
Anushan Rajakulasingam

-----Original Message-----
From: Julian C. Dunn [mailto:jdunn@aquezada.com]
Sent: Tuesday, September 08, 2015 7:39 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Issues running Test Kitchen in Audit mode

The output indicates you’re running Chef Client 12.0.3 not 12.3.0.
Audit mode was added in 12.1.0.

  • Julian

On Tue, Sep 8, 2015 at 1:58 PM, Rajakulasingam, Anushan Anushan.Rajakulasingam@cibc.com wrote:

Hello all,

I’m attempting to use test kitchen with chef-audit to test some of my audits but running into the following error:

   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'

See below for debug info. This runs fine on the actual server but via test kitchen fails with the above message… any ideas?

Application Versions

Test Kitchen: 1.4.0
Chef-Client: 12.3.0
Chefdk: 0.6.2 Release: 1.el6

Kitchen YML File


driver:
name: ssh
hostname: <%= ENV[‘vagrant_ip’] %>
port: '22’
username: username
password: xxxxxxxx

provisioner:
name: chef_zero
client_rb:
audit_mode: :audit_only
platforms:

  • name: rhel-6.3

suites:

  • name: default
    run_list:
    • recipe[test-audit::default]
      attributes:

default.rb Recipe/Audit

Cookbook Name:: test-audit

Recipe:: default

Copyright © 2015 The Authors, All Rights Reserved.

control_group ‘Blog Post Examples’ do
control ‘SSH’ do
it ‘should be listening on port 22’ do
expect(port(22)).to be_listening
end
end
end

Trace from Test Kitchen

-----> Starting Kitchen (v1.4.0)
-----> Cleaning up any prior instances of Destroying
-----> …
Kitchen-ssh does not destroy your server ‘’ by shutting it down…
Shutdown your server ‘’ natively with user ''
in your cloud or virtualisation console etc.\n
Finished destroying (0m0.00s).
-----> Testing
-----> Creating …
Kitchen-ssh does not start your server ‘10.126.69.72’ but will look for an ssh connection with user ‘vagrant’
[SSH] Established
Kitchen-ssh found ssh ready on host ‘10.126.69.72’ with user ‘vagrant’

   Finished creating <default-rhel-63> (0m1.21s).

-----> Converging …
$$$$$$ Running legacy converge for ‘Ssh’ Driver
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 3.3.0…
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to
Starting Chef Client, version 12.0.3
[2015-09-08T13:42:37-04:00] WARN: Child with name ‘dna.json’ found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
resolving cookbooks for run list: [“test-audit::default”]
Synchronizing Cookbooks:
- test-audit
Compiling Cookbooks…

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb

======================================================================

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

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:7:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/test-audit/recipes/default.rb:

     1:  #
     2:  # Cookbook Name:: test-audit
     3:  # Recipe:: default
     4:  #
     5:  # Copyright (c) 2015 The Authors, All Rights Reserved.
     6:
     7>> control_group 'Blog Post Examples' do
     8:    control 'SSH' do
     9:      it 'should be listening on port 22' do
    10:        expect(port(22)).to be_listening
    11:      end
    12:    end
    13:  end
    14:


   Running handlers:
   [2015-09-08T13:42:37-04:00] ERROR: Running exception handlers
   Running handlers complete
   [2015-09-08T13:42:37-04:00] ERROR: Exception handlers complete
   [2015-09-08T13:42:37-04:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   Chef Client failed. 0 resources updated in 8.00419466 seconds
   [2015-09-08T13:42:37-04:00] ERROR: No resource or method named `control_group' for `Chef::Recipe "default"'
   [2015-09-08T13:42:39-04:00] FATAL: 

Chef::Exceptions::ChildConvergeError: Chef run process exited
unsuccessfully (exit code 1)

Converge failed on instance .
Please see .kitchen/logs/default-rhel-63.log for more details
------Exception-------
Class: Kitchen::ActionFailed
Message: SSH exited (1) for command: [sh -c ’

sudo -E /opt/chef/bin/chef-client --local-mode --config
/tmp/kitchen/client.rb --log_level auto --force-formatter --no-color
–json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889 ']


Thanks,
Anushan Rajakulasingam


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]