Specifying a chef-client version with test kitchen

1,715 views
Skip to first unread message

Alex Corvin

unread,
Apr 29, 2014, 1:25:13 PM4/29/14
to testing-...@googlegroups.com
Some of our cookbooks are targeted to a 10.x version of chef, rather than chef 11. We are able to test this by specifying a version of chef in our Vagrantfile, but I haven't found a way to specify this using test-kitchen. Does anyone know of a way to do this?

Mischa Taylor

unread,
Apr 29, 2014, 3:20:49 PM4/29/14
to testing-...@googlegroups.com
You can pass in a version string on the "require_chef_omnibus:" config value passed into your Test Kitchen  driver.  For example, this will get test kitchen to load up version 10.24.0 of the client client instead of the latest version:


---

driver:

  require_chef_omnibus: 10.24.0

  name: vagrant


provisioner:

  name: chef_solo


platforms:

  - name: opscode-ubuntu-13.10

    driver:

      box: opscode-ubuntu-13.10

      box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box


suites:

  - name: default

    run_list:

    attributes:


  
Here's more documentation on require_chef_omnibus: config parameter:

Determines whether or not a Chef Omnibus package will be
installed. There are several different behaviors available:

* `true` - the latest release will be installed. Subsequent converges
  will skip re-installing if chef is present.
* `latest` - the latest release will be installed. Subsequent converges
  will always re-install even if chef is present.
* `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
  be passed the the install.sh script. Subsequent converges will skip if
  the installed version and the desired version match.
* `false` or `nil` - no chef is installed.

The default value is unset, or `nil`.

Mischa Taylor

unread,
Apr 29, 2014, 3:29:07 PM4/29/14
to testing-...@googlegroups.com
Miah also has a great example of using erb templates test with multiple versions of chef: https://github.com/miah/chef-redis/blob/master/.kitchen.yml

FYI: This can also be moved down to the suite level, if you want to test with multiple Chef versions:


---

driver:

  name: vagrant


provisioner:

  name: chef_solo


platforms:

  - name: opscode-ubuntu-13.10-chef10

    driver:

      require_chef_omnibus: 10.24.0

  - name: opscode-ubuntu-13.10-chef11

    driver:

      require_chef_omnibus: latest

Alex Corvin

unread,
Apr 29, 2014, 4:54:44 PM4/29/14
to testing-...@googlegroups.com
That is exactly that I needed. Thanks Mischa!
Reply all
Reply to author
Forward
0 new messages