Failed to install cookbooks from lockfile

During Chef cookbook testing with Test Kitchen only one “converge” action can update the Policyfile.lock.json at a time. If you test multiple recipes in the same cookbook, wait for the “Updating policy lock using /usr/local/bin/chef-cli update” message before starting the next converge otherwise we get the error message: STDOUT: Installing cookbooks from lockSTDERR: Error: Failed …

Error: Failed to install cookbooks from lockfile

When the CI/CD pipeline loads dependency cookbooks from GitHub and the kitchen converge process throws the error: Error: Failed to install cookbooks from lockfileReason: (CookbookOmnifetch::NotACookbook) The resource at ‘/…’ does not appear to be a valid cookbook. Does it have a metadata.rb? make sure the remote revisions of the dependency cookbook match in the caller …

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

When we launch a test instance with Chef Test Kitchen, we may get the error message: —–> Starting Test Kitchen (…)—–> Creating …——Exception——->>>>>> Class: Kitchen::ActionFailed>>>>>> Message: 1 actions failed.>>>>>> Failed to complete #create action: [undefined method `[]’ for nil:NilClass] on …>>>>>> ———————->>>>>> Please see .kitchen/logs/kitchen.log for more details>>>>>> Also try running kitchen diagnose –all for …

Failed to complete #converge action: [password is a required option]

The Chef Test Kitchen EC2 driver can connect to Windows instances two ways. Using a custom image with known admin account credentials When we use a custom built image which has a local administrator account with known username and password, specify it in the kitchen.yml file. Standard Amazon AMI with random password When we use …

Set the environment name in Chef Test Kitchen

To specify the environment name in the .kitchen.yml file Create a JSON environment file. Chef Zero used by Test Kitchen does not understand YAML or Ruby, we need to use JSON. In your cookbook’s root directory create a directory for environment files Create the myenv.json environment file in the environments directory. Specify the environment name …

Change the AWS account to launch instances with Chef Test Kitchen

The Chef SDK contains Test Kitchen, that can launch server instances to test your Chef cookbooks. Test Kitchen uses the “chef_zero” provisioner to use your workstation as the virtual Chef server. To switch Test Kitchen to launch instances in another AWS account In the .kitchen.yml file update the availability_zone subnet_id aws_ssh_key_id (if different in each account) …

Test your cookbook in Chef Test Kitchen against multiple versions of the Chef Client

In large environments, during the Chef Client version change, some older servers still run the prior version of the Chef Client, the newly created servers launch with the new version of the Chef Client. It is very important to test your cookbooks with the old and the new versions of Chef Client. To specify the …

Chef exit codes

Chef uses the standard RFC 062 exit codes. In your .kitchen.yml file, you can supply an array of exit codes in the “retry_on_exit_code” option to retry the operation in case the Chef script execution is interrupted. The usual values are retry_on_exit_code: # An array of exit codes that can indicate that kitchen should retry the converge …

FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe’s request.

When your Chef recipe requests a reboot using the “reboot” Chef resource, the output window shows an error message: Chef Client finished, …/… resources updated in … seconds […] WARN: Rebooting server at a recipe’s request. Details: {:delay_mins=>1, :reason=>”…”, :timestamp=>…, :requested_by=>”…”} Running handlers: […] ERROR: Running exception handlers Running handlers complete […] ERROR: Exception handlers complete Chef …