From 9e18803b955736b40ad1462a2d14aa2af1b4835f Mon Sep 17 00:00:00 2001 From: Torben Date: Sat, 8 Mar 2014 14:40:32 +0100 Subject: [PATCH] if the vagrant-omnibus plugin is detected and enabled for that VM, set the `OMNIBUS_DOWNLOAD_DIR` env var --- .../action/configure_bucket_root.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/vagrant-cachier/action/configure_bucket_root.rb b/lib/vagrant-cachier/action/configure_bucket_root.rb index 0630378..f041720 100644 --- a/lib/vagrant-cachier/action/configure_bucket_root.rb +++ b/lib/vagrant-cachier/action/configure_bucket_root.rb @@ -15,11 +15,32 @@ module VagrantPlugins if !env[:cache_buckets_folder_configured] && env[:machine].config.cache.enabled? setup_buckets_folder env[:cache_buckets_folder_configured] = true + if cache_vagrant_omnibus? + setup_omnibus_cache_folder + end end @app.call env end + def cache_vagrant_omnibus? + plugin_defined = defined?(VagrantPlugins::Omnibus::Plugin) + puts "xxx - cap: vagrant-omnibus defined? #{plugin_defined}" + return false unless plugin_defined + + chef_version = @env[:machine].config.omnibus.chef_version + puts "xxx - cap: chef_version? #{chef_version}" + return chef_version != nil + end + + def setup_omnibus_cache_folder + # since it's not configurable via the vagrant-omnibus plugin (yet) + # we specify the directory where to download the omnibus package here + omnibus_cache_dir = File.join(cache_root.to_s, 'omnibus') + FileUtils.mkdir_p(omnibus_cache_dir) unless File.exist? omnibus_cache_dir + ENV['OMNIBUS_DOWNLOAD_DIR'] = "/tmp/vagrant-cache/omnibus" + end + def setup_buckets_folder FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?