Till now I have been testing my chef cookbooks using kitchen on my laptop, which means that it’s done with vagrant and virtualbox as its provider. One of the things I wanted to try is to add jenkins in the whole process. I can only have a jenkins server as a KVM guest so this means that I can not have virtualbox as vagrant’s provider since VirtualBox can not run inside KVM. But LXC containers can run inside KVM. I would like to use LXC containers as an alternative vagrant provider since I would be doing my cookbooks’ testing on my laptop. This means that I should either manually change my .kitchen.yml file each time I want to use a different provider and execute “kitchen test” or execute kitchen with defining which config file it should be using. There is no such argument for kitchen.
While searching around I found a solution. You can define which kitchen yaml file it would be executed with the following way
$ KITCHEN_YAML="alternative_kitchen.yml" kitchen test
So in my cookbook I have two yaml files for kitchen, one .kitchen.yml which is executed when testing on my laptop with just “kitchen test” and one .kitchen-lxc.yml which is executed from jenkins as an “execute shell build step”
$ KITCHEN_YAML=".kitchen-lxc.yml" kitchen test