Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control the version of Chef that Vagrant uses to provision VMs?

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?

like image 440
Steve Bennett Avatar asked Jul 04 '12 08:07

Steve Bennett


People also ask

What does Vagrant Provision do?

Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process. This is useful since boxes typically are not built perfectly for your use case.

What is Vagrant in chef?

"Vagrant is free and open-source software for creating and configuring virtual development environments. It can be seen as a wrapper around virtualization software such as VirtualBox, KVM, VMware and around configuration management software such as Chef, Salt or Puppet." - wiki.


2 Answers

Using the Vagrant plugin vagrant-omnibus worked great for me:

vagrant plugin install vagrant-omnibus 

You can then simply configure your chef version in the Vagrantfile before doing the provisioning:

config.omnibus.chef_version = :latest 

You can also specify a specific version:

config.omnibus.chef_version = '11.6.0' 
like image 73
mirkokiefer Avatar answered Sep 30 '22 20:09

mirkokiefer


Add the lines

config.vm.provision :shell, :inline => 'apt-get install build-essential ruby1.9.1-dev --no-upgrade --yes' config.vm.provision :shell, :inline => "gem install chef --version 11.4.2 --no-rdoc --no-ri --conservative" 

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

like image 27
Bryan Larsen Avatar answered Sep 30 '22 21:09

Bryan Larsen