Reputation: 12144
Every time I vagrant destroy then vagrant up the Vagrantfile processing goes out and fetches the same old Chef it did last time.
config.omnibus.chef_version = :latest
How do I avoid downloading 34MB every single time? Sometimes I do want to restart from scratch rather than use vagrant provision.
I watched where it fetched the Chef from, downloaded it myself to
/Users/jluc/kds2/chef/vagrant/chef_11.14.6-1_amd64.deb
By commenting out the chef_version directiveI was kinda hoping to use install_url, but it doesn't seem happy with my file.
#config.omnibus.chef_version = :latest
config.omnibus.install_url = '/Users/jluc/kds2/chef/vagrant/chef_11.14.6-1_amd64.deb'
Skipping the install_url and pointing chef_version to my downloaded file did not help either.
The doc (https://github.com/schisamo/vagrant-omnibus) says install_url should be an install script. How do I use the normal install script, but use my downloaded file?
@Peter
Great. Sounds like it would work, but having trouble getting it to. I have this in an install script which I reference in the Vagrantfile It works from vagrant ssh
#!/usr/bin/env bash
dpkg --install /vagrant/chef_11.14.6-1_amd64.deb
but not from the Vagrantfile:
config.omnibus.install_url = '/vagrant/utilities/chefinstall.sh'
Upvotes: 3
Views: 1135
Reputation: 12144
Peter's suggestion about adding chef_version makes it work just fine.
That's the correct answer, I am just leaving this write up because it gives more context on the directory structure which is something I always struggle with with Chef docs.
config.omnibus.chef_version = '11.14.6'
config.omnibus.install_url = install_url
Details:
(note: Not looking at vagrant-cachier because I am trying to limit my dependencies on non-core (Opscode) cookbooks/plugins. Getting Berkshelf stable took me the better part of a week on OSX Mavericks).
The install script, chefinstall.sh:
#!/usr/bin/env bash
dpkg --install /vagrant/chef_11.14.6-1_amd64.deb
This is my setup, directory-wise
|-- Vagrantfile
|-- chef_11.14.6-1_amd64.deb
|-- utilities
| |-- chefinstall.sh
From the host, this is what the permissions look like:
audrey:utilities jluc$ ls -l chefinstall.sh
-rwxr-xr-x 1 jluc staff 68 10 Sep 12:19 chefinstall.sh
And from the guest, just in case:
vagrant@vagrant:~$ ls -l /vagrant/utilities/chefinstall.sh
-rwxr-xr-x 1 vagrant vagrant 68 Sep 10 12:19 /vagrant/utilities/chefinstall.sh
This is what I put in the Vagrantfile, no success until I added the chef_version as per Peter's suggestion.
#relative (to Vagrantfile) on host
install_url = './utilities/chefinstall.sh'
puts "jlp:install_url:#{install_url}:"
This is what Pete found that makes it work, adding the chef_version:
config.omnibus.chef_version = '11.14.6'
config.omnibus.install_url = install_url
Before the chef_version, I found that this hack was working as well.
config.vm.provision :shell, :inline => "sudo /vagrant/utilities/chefinstall.sh"
Upvotes: 0
Reputation: 5190
The vagrant-omnibus plugin allows you to give any script to install chef. So if you put the chef install into the folder where the Vagrantfile is, you could point to an install script that looks like:
#!/usr/bin/env bash
dpkg --install /vagrant/chef_11.14.6-1_amd64.deb
Put it in the same folder as your Vagrantfile. Then in your Vagranfile:
config.omnibus.chef_version = '11.14.6'
config.omnibus.install_url = './chefinstall.sh'
That should work. It's clever enough that it'll check what version of Chef is installed on the box, and only run the script if that's missing.
You could also use the vagrant cachier plugin, so it won't have to download everytime, the newest version of the omnibus plugin hooks into the cache:
config.omnibus.cache_packages = true
So if your main concern is having to download repeatably, check out vagrant-cachier
Upvotes: 3