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 […]

chef push always regenerates the revision id and Policyfile.lock.json

If the chef update and chef push commands always regenerate the Policyfile.lock.json file and the revision_id in it, make sure the Chef cookbook contains the chefignore file and it also references all possible Policyfile lock files: If a cookbook file changes, a new Policyfile.lock.json is generated during chef push. chef update and chef push always check […]

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 […]

Test Chef cookbooks with Docker containers

Kitchen Dokken is a provisioner to test cookbooks in Docker containers. It is very fast and efficient compared to cloud instances like AWS EC2s, Vagrant boxes, or VMWare virtual machines. Currently, you can only test Linux cookbooks with Kitchen Dokken. To generate a cookbook with the dokken provisioner use the –kitchen option The Kitchen Dokken […]

Is the Chef aws_s3_file resource idempotent?

Yes, it is idempotent. It means, when the target file on the local drive matches the source file in the S3 bucket, Chef Client does not download the file. In the past aws_s3_file was not idempotent, but now behind the scenes it calls remote_file which compares the files and skips the download when the files […]

Chef FATAL: IndexError: string not matched

Chef attributes are “Mash” type. From the Ruby Doc: “Mash allows you to create pseudo-objects that have method-like accessors for hash keys.” Mash is inherited from Hash. Attributes can hold any data type, but we need to make sure the type does not change as we create more attributes. In this example we change the […]

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 […]

Generate the Chef cookbook dependency diagram

The Brew viz command reads the Berksfile.lock in the current Chef cookbook directory and saves the cookbook dependency diagram in the graph.png file. The command requires the graphviz utility Install graphviz In the terminal window execute Generate the cookbook dependency diagram and open it in Preview In the Chef cookbook directory execute If you get […]

Failed to complete #create action: [You are not authorized to perform this operation

When launching an instance in AWS with Chef Test Kitchen you get the error message >>>>>> Failed to complete #create action: [You are not authorized to perform this operation. Encoded authorization failure message:… Make sure the image does not require the acceptance of the license before you first use it. This applies to Ubuntu, CentOS