Chef / Vagrant - how to point the omnibus installer to an already downloaded file?

Every time I wander, it destroys and then vagrant up the Vagrantfile processing goes out and gets the same old chef as last time.

config.omnibus.chef_version = :latest

      

How to avoid downloading 34 MB every time? Sometimes I want to restart from scratch and not use vagrancy .

I watched where he got the chef from, loaded it myself into

/Users/jluc/kds2/chef/vagrant/chef_11.14.6-1_amd64.deb

      

After commenting out the chef_version directive, I kind of was hoping to use install_url, but I don't think he's 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'

      

Failed to skip install_url and point chef_version to downloaded file.

The doc ( https://github.com/schisamo/vagrant-omnibus ) says install_url should be an install script. How do I use a normal install script but use the downloaded file?

@Peter

Great. It looks like it will work, but it's hard to get it. I have this in the install script that I link in the Vagrantfile. It runs from the ssh vagrant

#!/usr/bin/env bash
dpkg --install /vagrant/chef_11.14.6-1_amd64.deb

      

but not from Vagrantfile:

config.omnibus.install_url = '/vagrant/utilities/chefinstall.sh'

      

+3


source to share


2 answers


The vagrant-omnibus plugin allows you to provide any script to install the chef. So if you put chef install in the folder where the Vagrantfile is located, you can point to an install script that looks like this:

#!/usr/bin/env bash
dpkg --install /vagrant/chef_11.14.6-1_amd64.deb

      

Place 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'

      



This should work. It's smart enough to check which version of Chef is installed on the box and only run the script if it's missing.

You can also use the firewall cachier plugin, so it doesn't have to download every time, the newest version of omnibus plugins connects to the cache:

config.omnibus.cache_packages = true

      

So if your main problem is loading repeatability check out vagrant-cachier

+3


source


Peter's suggestion to add chef_version makes it very good.

Correct answer: I just leave this entry because it gives more context in the directory structure that I always come across 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'm trying to limit my dependencies on non-core (Opscode) cookbooks / plugins. Getting a stable Berkshelf took me most of a week on OSX Mavericks).

Installation 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, without success until I added chef_version as suggested by Peter.

#relative (to Vagrantfile) on host 
install_url = './utilities/chefinstall.sh'

puts "jlp:install_url:#{install_url}:"

      

This is what Pete found, which makes it work by adding chef_version:

config.omnibus.chef_version = '11.14.6'
config.omnibus.install_url = install_url

      

Prior to chef_version, I found this hack works as well.

config.vm.provision :shell, :inline => "sudo  /vagrant/utilities/chefinstall.sh"

      

0


source







All Articles