Closed martinmosegaard closed 2 years ago
Thanks for asking this question! There are multiple aspects to this, the direction your question is leaning is towards using test kitchen to manage updating the provisioner (chef in this case).
I'm going to give an answer that is specific to managing the node and using chef to do so as this might be something you run into on your production nodes as well. just like anything else on a node, it needs to be managed by chef to be updated. You can use https://github.com/chef-cookbooks/chef_client_updater.
I'm going to look more into the test kitchen side of things to see whether there is a way to reinstall the provisioner as well driven by test kitchen and also look into what kind of document should exist to answer the "how to update chef-client".
Can you share your kitchen configuration please?
@martinmosegaard I just tested and that setting works as expected.
I tested by doing a chef generate cookbook and just updating the configuration starting with 12.9.38 as the configuration, and then changing to 13. Here is my kitchen.yml:
---
driver:
name: vagrant
require_chef_omnibus: "13"
provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true
verifier:
name: inspec
platforms:
- name: ubuntu-16.04
- name: centos-7
suites:
- name: default
run_list:
- recipe[test_chef_client::default]
verifier:
inspec_tests:
- test/smoke/default
attributes:
Thanks for your investigations. It still doesn't work for me :( Here is my .kitchen.yml
and converge output.
.kitchen.yml
:
---
driver:
name: vagrant
require_chef_omnibus: "13"
provisioner:
name: chef_zero
install_msi_url: http://our-own-repo/chef-client-13.4.19-1-x64.msi
always_update_cookbooks: true
verifier:
name: inspec
platforms:
- name: win2012r2
os_type: windows
driver:
box: win2012r2-datacenter-chef
box_url: http://our-own-repo/win2012r2-datacenter-cheflatest-1.0.4.box
linked_clone: true
guest: windows
communicator: winrm
gui: true
suites:
- name: default
run_list:
- recipe[myrecipe::default]
attributes:
And converge output:
λ kitchen converge
-----> Starting Kitchen (v1.15.0)
-----> Converging <default-win2012r2>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 5.6.4...
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected ()
Transferring files to <default-win2012r2>
Starting Chef Client, version 12.9.38
resolving cookbooks for run list
...
What version of kitchen are you using?
Test Kitchen version 1.15.0. I see you are using 1.17. I can't spot anything in https://github.com/test-kitchen/test-kitchen/blob/master/CHANGELOG.md though
This might help: provisioner: name: chef_zero product_name: chef # Install the Chef Client product_version: 14.0.0 # Set the Chef Client version, default=latest install_strategy: always # Forces the installation of the specified Chef Client version even if another version is installed
Note: If the installed Chef Client version is newer than the specified version, Test Kitchen downloads the specified version but executes the already installed newer version.
Closing this. It looks like the newer install_strategy
setting should fix this, or possibly it was a bug in an older version of Test Kitchen.
Usecase: I have a vagrant box that I use for my kitchen tests. It has chef-client v12.9.38 installed. I want to force an update of chef-client to v13. In
.kitchen.yml
I can specify versions orlatest
forrequire_chef_omnibus
. But it seems to be ignored.This page doesn't explain what to do in order to force an update: https://docs.chef.io/config_yml_kitchen.html
Then there is this group post suggesting that
latest
will always reinstall chef even if present. But it doesn't work for me: https://groups.google.com/forum/#!topic/testing-with-chef/f4LGcLXinfMCan we put some clarification in the documentation?