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

RuntimeError: Volume vol-… attached at xvdf but does not conform to this resource’s specifications

When the Chef aws cookbook’s ebs_volume.rb resource tries to bring a volume online, partition, and format it we get the error message: RuntimeError: Volume vol-… attached at xvdf but does not conform to this resource’s specificationsC:/chef/cache/cookbooks/aws/resources/ebs_volume.rb:46:in `block in class_from_file’ Make sure the “size” attribute value in the aws_ebs_volume resource call matches the actual size of […]

Migrating from Chef Client version 13 to 15

Syntax changes There are breaking changes between Chef Client version 13 and the newer versions, make sure you update your Chef cookbooks to make them work with the new version of the Chef Client. Resource Since version Old syntax New syntax Notes logger Client 14.0 keyword, cannot use it as a variable or parameter name […]

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