3

Every time I run kitchen verify for the first time after creating a box, it needs to download the chef-client. E.g:

 downloaded metadata file looks valid...
       downloading https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.4.1-1.el6.x86_64.rpm
         to file /tmp/install.sh.2340/chef-12.4.1-1.el6.x86_64.rpm

I have a poor Internet connection so this takes a long time. Is there a simple way to cache the RPM so I don't have to download it each time?

rouan
  • 5,339
  • 6
  • 22
  • 36

2 Answers2

4

I haven't been able to cache the RPM through Kitchen, but I have solved the problem by downloading the file myself and providing it to Kitchen.

  • Download RPM file
  • Put it in a local folder alongside your .kitchen.yml. e.g. chef-pkgs
  • Kitchen downloads chef packages to a /tmp directory, so set up a synced folder in your .kitchen.yml with the chef-pkgs folder. Example:

Example .kitchen.yml:

driver:
  name: vagrant
  vagrantfiles:
    - Vagrantfile
  synced_folders:
    - ["./chef-pkgs", "/tmp/chef-pkgs"]

provisioner:
  name: chef_zero
  require_chef_omnibus: 12.4.1
  chef_omnibus_url: file:///tmp/chef-pkgs/install.sh
  • Create an install.sh file in your chef-pkgs folder that installs the RPM from the cached location.

Example install.sh:

#! /bin/bash
sudo rpm -ivh /tmp/chef-pkgs/chef-12.4.1-1.el6.x86_64.rpm

I got the idea and code from this helpful blog post: http://erichelgeson.github.io/blog/2014/09/23/simple-chef-package-cache/

I added the chef-pkgs folder to my .gitignore file.

rouan
  • 5,339
  • 6
  • 22
  • 36
0

It might be important to note that current kitchen versions are now treating this option as deprecated, e.g. running a fairly recent chef workstation gives you chefdk 3.7.* bundled with 1.24.* - so you might face similar output:

-----> Starting Kitchen (v1.24.0)
$$$$$$ Deprecated configuration detected:
chef_omnibus_url
Run 'kitchen doctor' for details.

Find out more under ChefRFC901. As of now, I wasn't able to install chef from a file shared into the vm by any means, but there is still the option to overwrite the metadata url and serve them via "local" http.