chef-infratest-kitchen

How do I get Test Kitchen to cache the chef-client RPM?


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?


Solution

  • 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.

    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
    

    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.