if the vagrant-omnibus plugin is detected and enabled for that VM, set the OMNIBUS_DOWNLOAD_DIR env var

This commit is contained in:
Torben 2014-03-08 14:40:32 +01:00
parent 2df1e31940
commit 9e18803b95

View file

@ -15,11 +15,32 @@ module VagrantPlugins
if !env[:cache_buckets_folder_configured] && env[:machine].config.cache.enabled? if !env[:cache_buckets_folder_configured] && env[:machine].config.cache.enabled?
setup_buckets_folder setup_buckets_folder
env[:cache_buckets_folder_configured] = true env[:cache_buckets_folder_configured] = true
if cache_vagrant_omnibus?
setup_omnibus_cache_folder
end
end end
@app.call env @app.call env
end 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 def setup_buckets_folder
FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist? FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?