Test Kitchen is a common tool for integration testing of Chef cookbooks. Usually a combination of Vagrant&VirtualBox is used to bring up the VMs. This works well for local development setups, but what about Continuous Integration environments? You can find several approaches how cookbooks can be tested in the CI:
- if your CI runs on non-persistent VMs (like Travis CI) you might use kitchen-dokken like chef-ssh-hardening does
- you can use kitchen providers like kitchen-digitalocean or kitchen-ec2
Well, but what about the case you want to use Vagrant&VirtualBox in the CI too? There are some reasons for this approach:
- Maybe you can not use public cloud providers for some reasons and do not have your own on-premise cloud like OpenStack
- Maybe you want to use the same setup/technologies in the CI and locally as you want be able to easy reproduce errors and problems
This post covers a basic GitLab CI setup with Test Kitchen and Vagrant&VirtualBox as backend.
I have a non-flat network with subnetworks at home and I wanted to enable IPv6 in dual stack mode for the desktop systems. This blog post describes this setup and configuration for:
Chef has different execution phases. Especially the compile and converge phase are important when writing cookbooks: the resources are collected in the compile phase and are executed in the converge phase.
In some special cases you might want to have dynamic resources, which are created and executed in the converge phase. The main background is that you want to react on something you known in the execution phase only.
Given a situtation where you want to cleanup configuration files, which get installed by some package during a chef run (real examples might be apache on debian or freeradius on RHEL). You can try to solve this situation like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
However this will not work: you try to glob over
/etc/raddb/mods-available in the compile phase, but this path doesn’t exist as freeradius gets installed in the converge phase.
Usually the inspec tests are describing a particial resource:
1 2 3
However in some case it might be useful to use the common RSpec style with nested
Sometimes you might need some generic functions, which are used in several cookbooks in your environment. In this case it makes sense to create a cookbook, which contains this functions.
Chef Development Kit contains a chef-dk gem with
chef generate is a pretty usefull command for generation of skelettons.
Per default the information like author, license or email looks like this:
1 2 3 4 5 6
How to get your own data instead of this defaults?
Hybrid suspend is a suspend mode, where suspend-to-disk and suspend-to-ram are executed together in the same time. Its a quite usefull mode for notebooks:
- fast wake up because of suspend-to-ram
- no data loss in case of empty battery during the suspend
Docker docs and ACI docs decsribe the steps how to create base images from existing tarballs/folders with root file systems of distribution. If you make a deeper look, you will probably find the CentOS tarballs which are used by docker for creation of centos base images.
But how to get this root file system tree? This blogpost covers the creation of this root file system tree for CentOS and the creation of base images for Docker and Rkt.
Chef is building omnibus packages only for x86. But probably you want to run chef on raspberry pi 3 with ARM. There is a blogpost, which describes the chef installation on Raspbian. This blogpost covers the steps for chef installation on raspberry pi with centos.