A current Chef recipe isn't running because of a bug in version 0.10.10. How can I upgrade the version of Chef that Vagrant uses, to 0.10.12?
I don't want to just update it for the current instance of the VM - I keep destroying and rebuilding those. Do I need to change something in the Vagrant base box, or something in my (physical) system's installation?
Rebuild the base box. First, bring it up without provisioning and SSH to it.
Then, perform the commands you need to update the box. This can include updating Chef and Ruby. Optionally, update the packages for the OS, etc. You should clean up the box of everything that isn't required, such as downloaded package files or caches.
For example, I use the Opscode Omnibus Full Stack Installer for Chef in my Vagrant boxes (originally built with VeeWee), and I update the packages, too.
Don't forget to "zero" the disk to reduce the size.
Then, package the box up and add it to your Vagrant environment for use.
If you want to use the same box name, you'll need to remove the existing box (~/.vagrant.d/boxes/BOXNAME) first.
Add the lines
to your Vagrantfile before your
config.vm.provision :chef_solo
block.props to hauraki's comment on http://dougireton.com/blog/2012/12/23/automatically-upgrading-chef-client-on-vagrant-up/
edited to include Jason Mayfield's comment. Make sure and give him an upvote too. I added
--no-upgrade
to speed things up and match the--conservative
on the second line. You could instead do what Jason did, and remove both the--no-upgrade
and--conservative
.edited to include suggested edit by anonymous user228653
Using the Vagrant plugin vagrant-omnibus worked great for me:
You can then simply configure your chef version in the Vagrantfile before doing the provisioning:
You can also specify a specific version:
If you are using Chef Test Kitchen, then you can specify the Chef version in
.kitchen.yml
file, like this:There are a number of options you can specify when using Chef for provisioning. One of these is
version
, which allows you to specify the Chef version you want.For example, see the
chef.version
line in this extract from aVagrantfile
of mine:I am unable to post comments on answers, but I wanted to add a note to Bryan Larsen's answer above. In order to get his provisioning command to work, I needed to add a line before it to be able to build the gem native extensions during install of the new Chef version. Therefore, it became:
This was on Ubuntu 13.04, in case that matters to anyone.