xtoddx / weekend-hacks

Issue tracker for my ideas, wiki for implementation notes
1 stars 0 forks source link

Vagrant caching #3

Closed xtoddx closed 9 years ago

xtoddx commented 11 years ago

There are a few annoyances with Vagrant provisioning I want to address.

Rvm installation via chef-solo

vagrant-cachier + chef-rvm doesn't cache the way I think it should. I've worked around some of the problem but the initial get.rvm.io script is still gets downloaded, and the installer is downloaded to /usr/local/rvm/archives instead of the rvm_archives_path that I've asked the rvmrc to download things to (/tmp/vagrant-cache/rvm/rvm).

I need to find out why the archives path isn't overwritten during that first run, since curl should only re-download if the file mismatches (I think, I haven't confirmed curl works that way).

There may be some work to do to get chef-rvm more in tune with offline rvm installation so that we never have to trust a file downloaded from an internet server not under our control while we're provisioning servers that we may be sensitive about.

vagrant-omnibus

vagrant-omnibus works the same way as rvm, grabbing an install script from the web and executing it. There is an is an open issue discussing the way to do this, but it doesn't seem to be making much progress.

xtoddx commented 9 years ago

Done, many times over with a cache function that I put in the Vagrantfile

def cache config, name, guest_path
  require 'fileutils'
  require 'pathname'
  name = name.to_s
  local = File.join(File.expand_path('~/.vagrant.d/cache'), config.vm.box, name)
  FileUtils.mkdir_p local
  config.vm.synced_folder local, guest_path
end

# in config.vm.define('myapp') do |app|
# but could also just pass the "config" from Vagrant.configure('2') do |config|
    cache app, :apt, '/var/cache/apt/archives'
    cache app, :chef, '/var/chef/cache'
    cache app, :gem, '/var/lib/gems/2.1.0/cache'