Search code examples
windowsvagrantchef-infraberkshelftest-kitchen

Chef Kitchen can't find current cookbook during 'kitchen converge' on Windows


I had a cookbook that was working fine, and then I updated to the latest version of kitchen and now it's throwing errors during a converge. I've tried doing a converge on a cookbook that doesn't have any dependencies and that worked fine, so I'm guessing that it may be something to do with berks?

EDIT: The line that's failing is:

$env:systemdrive\opscode\chef\bin\chef-client.bat --local-mode --config $env:TEMP\kitchen\client.rb --log_level auto --force-formatter --no-color --json-attributes $env:TEMP\kitchen\dna.json --chef-zero-port 8889

which is being run on the WindowsServer 2012 RC2 VirtualBox. From looking at the kitchen folder in the temp directory, it looks like none of the cookbooks are getting copied across to the virtual machine.

When I run a converge on a simple test cookbook, that has no depenencies, I can see that the kitchen folder on the virtual machine has the cookbook folder, and the converge succeeds.

EDIT 2:

I added a dependency to the working cookbook, added a Berksfile (same as the one in the bottom of this post) and did berks install and it threw an SSL_connect error

C:/tools/ruby22/lib/ruby/gems/2.2.0/gems/httpclient-.7.2/lib/httpclient/ssl_socket.rb:46:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)

Which is the same as the error in this post: https://github.com/chef/chef-dk/issues/106

Running the powershell fix which is:

Invoke-WebRequest http://curl.haxx.se/ca/cacert.pem -OutFile c:\cacert.pem
Set-Item -Path env:SSL_CERT_FILE -Value C:\cacert.pem

Resolves the error, but then after running kitchen converge I run into the same issue where I have no cookbooks on the virtual machine. I'm pretty sure now that these two problems are related.

More details below


These are the versions I'm currently using:

Chef Development Kit Version: 0.12.0
chef-client version: 12.9.38
berks version: 4.3.2
kitchen version: 1.7.3

And this is the error (mock_emr is the name of the cookbook I'm trying to converge):

-----> Starting Kitchen (v1.7.3)
-----> Converging <default-windows-2012r2>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 4.3.2...
       Removing non-cookbook files before transfer
       Preparing data_bags
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)

       Creating the scheduled task.
       SUCCESS: The scheduled task "chef-tk" has successfully been created.
       Transferring files to <default-windows-2012r2>
       SUCCESS: Attempted to run the scheduled task "chef-tk".
       Connected to the scheduled task.
       Starting Chef Client, version 12.9.38
       resolving cookbooks for run list: ["mock_emr::default"]

       ================================================================================
       Error Resolving Cookbooks for Run List:
       ================================================================================

       Missing Cookbooks:
       ------------------
       No such cookbook: mock_emr

       Expanded Run List:
       ------------------
       * mock_emr::default

       Platform:
       ---------
       x64-mingw32


       Running handlers:
       [2016-04-25T15:57:51+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2016-04-25T15:57:51+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 34 seconds
       [2016-04-25T15:57:51+00:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-st
acktrace.out
       [2016-04-25T15:57:51+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug repor
t
       [2016-04-25T15:57:51+00:00] FATAL: Net::HTTPServerException: 412 "Precondition Failed"

My .kitchen.yml file is this:

---
driver:
  name: vagrant
  network:
    - ["private_network", {ip: "192.168.35.35"}]
  synced_folders:
    - ["../../.chef/secrets", "C:/chef"]

provisioner:
  name: chef_zero_scheduled_task

platforms:
  - name: windows-2012r2
    driver:
      customize:
        memory: 2048

suites:
  - name: default
    data_bags_path: "../../data_bags"
    run_list:
      - recipe[mock_emr::default]
    attributes:
      mock_emr:
        secret_file: 'C:/chef/encrypted_data_bag_secret'
      sql_server:
        sysadmins: ['Administrator', 'vagrant']

And the metadata.rb file:

name 'mock_emr'
maintainer 'The Authors'
maintainer_email 'author@example.com'
license 'all_rights'
description 'Installs/Configures mock_emr'
long_description 'Installs/Configures mock_emr'
version '0.1.0'

depends 'sql_server', '~> 2.5.0'
depends 'iis', '~> 4.1.6'

And the berksfile:

source 'https://supermarket.chef.io'

metadata

Solution

  • I believe that this was an issue with having ruby installed as well as the chef development kit. I think chef was trying to run through ruby and not the dev kit, and was having issues. I uninstalled both ruby and the dev kit, and reinstalled the dev kit, and now everything seems to be working correctly again.

    The clue that led me to this conclusion was that running chef verify failed saying omnibus wasn't configured correctly.