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 Chef cookbooks locally on a virtual workstation

When you use a virtual machine to write your Chef cookbooks you may want to test them locally with Vagrant. This nested virtual machine cannot use a 64 bit operating system, because to run a 64 bit virtual machine, the host computer’s CPU has to provide the CPU Extensions. Currently only physical CPUs can provide …

Migrating from Chef Client version 12 to 13

Chef is under heavy development, every new major version introduces new features, and many times changes, deprecates, or removes some commands or options. Chef Client 13 introduced a new way of handling reboots and Windows scheduled tasks. reboot resource In Chef version 12, the “:reboot_now” action continued the execution of the Chef cookbook but after …

Calling a resource in the Chef recipe

During major Chef Client version upgrades, some instructions need to be changed based on the version of the Chef Client. For example, upgrading from version 12 to version 13, the “windows_task” resource requires a different action to make changes to existing scheduled tasks. To call a Chef resource in your cookbook, you need another resource to …

Make decisions in your Chef recipe based on the version of the Chef Client

There are times when you have to make a decision in your Chef recipe, based on the version of the Chef Client installed on the node. There are two ways to get the version of the installed Chef Client: Chef::VERSION node[‘chef_packages’][‘chef’][‘version’] To make a decision based on the installed Chef Client version if ( Chef::VERSION.to_f …

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 …

windows_task, ArgumentError: invalid date

When the windows_task resource is called to “create” a Windows Scheduled Task that already exists, an error message is returned. In the past, the “modify” action was responsible for the modification of the scheduled tasks, since Chef 13 the “create” action would update the task if exists. ArgumentError: …[…] (…:… line …) had an error: ArgumentError: …

.NET Framework Detection in the Windows Registry

To determine which .NET framework is installed on the Windows computer check the values in the registry. The HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full key contains two values you can check: Release Version You can use InSpec, part of the Chef DK, to check the values: describe registry_key(‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full’) do it { should have_property ‘Release’ } it { …

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 …