Unable to satisfy constraints on package

When you make a change to the version restrictions in the metadata.rb file and execute berks install in your Chef cookbook directory, you may get the error message: Unable to satisfy constraints on package … due to solution constraint (…). Solution constraints that may result in a constraint on …: [(…)], [(…) -> (…)] Demand that …

Skip steps in an InSpec integration test based on Chef attribute values

To speed up the test of some complex recipes, I use an attribute to skip certain long-running installations when I only need to test the rest of the recipe. We will pass Chef Attribute values into an InSpec test using environment variables. Declare an attribute in the atrributes.rb file with a safe default value, to allow the …

Waiting for SSH service on …:22, retrying in 3 seconds

When you try to launch a new EC2 instance in AWS using Chef Test Kitchen and the process times out with the message:   Waiting for SSH service on …:22, retrying in 3 seconds $$$$$$ [SSH] connection failed, terminating (#<Net::SSH::AuthenticationFailed: Authentication failed for user …@…>) >>>>>> ——Exception——- >>>>>> Class: Kitchen::ActionFailed >>>>>> Message: 1 actions failed. …

Failed to complete #create action: [undefined method `version’ for nil:NilClass] on …

When you execute kitchen converge to launch an EC2 instance in AWS with Chef Test Kitchen, you get the error message: >>>>> ——Exception——- >>>>>> Class: Kitchen::ActionFailed >>>>>> Message: 1 actions failed. >>>>>> Failed to complete #create action: [undefined method `version’ for nil:NilClass] on … >>>>>> ———————- >>>>>> Please see .kitchen/logs/kitchen.log for more details >>>>>> Also …

Could not load the ‘ec2’ driver from the load path

When you execute kitchen list and the driver in your .kitchen file is “ec2“, the following error message appears: >>>> ——Exception——- >>>>>> Class: Kitchen::ClientError >>>>>> Message: Could not load the ‘ec2’ driver from the load path. Please ensure that your driver is installed as a gem or included in your Gemfile if using Bundler. >>>>>> ———————- …

No instances for regex `’, try running `kitchen list’ in Chef Test Kitchen

When I tried to execute the “kitchen list” command in Chef Test Kitchen the following error came up: No instances for regex `’, try running `kitchen list’ I could not find the reason for the error, so I opened the .kitchen.yml file in the Atom editor, added a space to one of the comments, and saved the …

Berks update fails with ‘Missing artifacts’ error message

When you add cookbooks as dependencies with the “depends” statement to the metadata.rb file of your Chef cookbook, to be able to test your cookbooks in Chef Test Kitchen, you also have to specify the location of those cookbooks in the Berksfile file. For all the cookbooks that are available on the Chef Supermarket, one line source …

Chef file locations

The Chef file and folder locations are different on Linux and Windows machines. This article explains the purpose of each file and the location. Summary Linux Windows Cookbook location /var/chef/cache/cookbooks  C:\chef\cache\cookbooks Chef Client run log /var/log/chef.log First run only C:\chef\chef-client.log Subsequent Chef client runs C:\chef\log\client.log Error log /var/chef/cache/chef-stacktrace.out C:\chef\cache\chef-stacktrace.out Ohai output /var/chef/cache/failed-run-data.json C:\chef\cache\failed-run-data.json Recommended location for …

Launch Windows instances locally with Chef Test Kitchen

Most Linux distributions are free, and do not require product keys to launch them. The steps below are based on the great article at http://kitchen.ci/blog/test-kitchen-windows-test-flight-with-vagrant/ I have summarized the steps below to create a free Virtual Box Windows Server 2012R2 image on your workstation, so Test Kitchen can use Vagrant and Virtual Box to launch Windows instances and test cookbooks …

`block in filter_instances’: undefined method `empty?’ for nil:NilClass (NoMethodError)

When you try to execute any of the “kitchen” commands in Chef Test Kitchen you may get the following error message. lib/kitchen/config.rb:182:in `block in filter_instances’: undefined method `empty?’ for nil:NilClass (NoMethodError) This happened in my cookbook, when I have removed the value from the “excludes:” option in the .kitchen.yml file, but left the “excludes:” option …