I am looking for the way to cache installation files for Vagrant environment assuming that boxes is properly populated from vagrant box add
. The idea is to be able to test/develop box provisioning in offline environment later after initial download steps or to save time on downloading same artifacts for identical node copies (for example if I want to run 10 identical slaves).
My initial thought is to download necessary files to Vagrant project to shared folder and use those files during provisioning (so I don't need to do repetitive curl
/wget
for each boxes).
I wrote:
$share = "share"
Dir.mkdir($share) unless Dir.exist?($share)
# https://pkg.jenkins.io/debian/
$jenkins_deb_url = "https://pkg.jenkins.io/debian/binary/jenkins_2.86_all.deb"
$jenkins_deb_file = $share+"/jenkins.deb"
if ! File.exist?($jenkins_deb_file)
require 'open-uri'
download = open($jenkins_deb_url)
IO.copy_stream(download, $jenkins_deb_file)
end
It isn't perfect. I can't automate downloading of apt-get install
dependencies reliably (that is necessary to satisfy dependencies for Jenkins) to make it completely offline.