diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b551fd..96f2bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ -## [0.5.2](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.1...master) (unreleased) +## [0.6.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.1...v0.6.0) (Feb 26, 2014) +BACKWARDS INCOMPATIBILITY: + + - Plugin activation is now triggered by the `cache.scope` config and that config + is now required. Previous versions of the plugin had it set to `:box` but + there is no consensus whether `:box` and `:machine` is better. This is to + highlight that you need to think about the caching strategy you are going + to use. For more information and to discuss this move please check [GH-17](https://github.com/fgrehm/vagrant-cachier/issues/17). + - Because `cache.scope` is now a requirement and in order to reduce the amount of + configuration required by the plugin, we enabled automatic bucket detection by + default. To revert to the old behavior you can disable it globally from your + `~/.vagrant.d/Vagrantfile`. + - Support for Vagrant < 1.4 is gone, please use a previous plugin version if + you are running Vagrant 1.2 / 1.3 + - Automatic handling of multiple machine scoped cache dirs from versions + prior to 0.3.0 of this plugin was removed. + - Support for `enable_nfs` has been deprecated and will be removed on 0.7.0, + please use `cache.synced_folder_opts = {type: :nfs}` instead. + +FEATURES: + + - Warm up cache buckets with files available on guest in case bucket is empty + - Support for offline provisioning of apt-packages by caching `/var/lib/apt/lists` [GH-84] + - Support for specifying custom cache bucket synced folder opts + - Support to force disabe the plugin [GH-72] + - Automatically disable the plugin for cloud providers [GH-45] + - Skip configuration of buckets that have been configured already [GH-85] + +BUG FIXES: + + - Properly fix NFS support for Vagrant 1.4+ [GH-76] ## [0.5.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.0...v0.5.1) (Dec 20, 2013) diff --git a/Gemfile b/Gemfile index 995df3d..af80dba 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source 'https://rubygems.org' gemspec group :development do - gem 'vagrant', github: 'mitchellh/vagrant' + gem 'vagrant', github: 'mitchellh/vagrant', tag: 'v1.4.3' gem 'vagrant-lxc', github: 'fgrehm/vagrant-lxc' gem 'vagrant-pristine', github: 'fgrehm/vagrant-pristine' gem 'vagrant-global-status', github: 'fgrehm/vagrant-global-status' diff --git a/Gemfile.lock b/Gemfile.lock index f0a5e13..2bbab2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,104 +1,129 @@ GIT remote: git://github.com/fgrehm/vagrant-global-status.git - revision: a0295400a0e47756cbcb8f97ed9f4449b1fb6b56 + revision: 8ae82e2c57b085a030137a40e9b3d232f42e5117 specs: - vagrant-global-status (0.1.1) + vagrant-global-status (0.1.5.dev) GIT remote: git://github.com/fgrehm/vagrant-lxc.git - revision: 225af5622767059708278db29d42941e93d41994 + revision: 1083f100adc4cf1bd20e7eb794ecfda94ef8b365 specs: - vagrant-lxc (0.6.4.dev) + vagrant-lxc (0.7.1.dev) GIT remote: git://github.com/fgrehm/vagrant-pristine.git - revision: 4638491786943bfbf6f115b1fc379f069963fe46 + revision: 503dbc47848c81d0fbfa6840491856f518d244a1 specs: vagrant-pristine (0.3.0) GIT remote: git://github.com/mitchellh/vagrant.git - revision: 57e95323b6600b146167f0f14f83b22dd31dd03f + revision: 4f0eb9504cc786d5a57a43814427e8eb35407a4c + tag: v1.4.3 specs: - vagrant (1.3.6.dev) + vagrant (1.4.3) childprocess (~> 0.3.7) erubis (~> 2.7.0) i18n (~> 0.6.0) log4r (~> 1.1.9) net-scp (~> 1.1.0) - net-ssh (~> 2.6.6) + net-ssh (>= 2.6.6, < 2.8.0) PATH remote: . specs: - vagrant-cachier (0.5.2.dev) + vagrant-cachier (0.6.0) GEM remote: https://rubygems.org/ specs: archive-tar-minitar (0.5.2) - chef (11.6.0) - erubis - highline (>= 1.6.9) + chef (11.8.2) + chef-zero (~> 1.6, >= 1.6.2) + diff-lcs (~> 1.2, >= 1.2.4) + erubis (~> 2.7) + highline (~> 1.6, >= 1.6.9) json (>= 1.4.4, <= 1.7.7) - mixlib-authentication (>= 1.3.0) - mixlib-cli (~> 1.3.0) - mixlib-config (>= 1.1.2) - mixlib-log (>= 1.3.0) - mixlib-shellout + mime-types (~> 1.16) + mixlib-authentication (~> 1.3) + mixlib-cli (~> 1.3) + mixlib-config (~> 2.0) + mixlib-log (~> 1.3) + mixlib-shellout (~> 1.2) net-ssh (~> 2.6) net-ssh-multi (~> 1.1.0) - ohai (>= 0.6.0) + ohai (~> 6.0) + pry (~> 0.9) + puma (~> 1.6) rest-client (>= 1.0.4, < 1.7.0) yajl-ruby (~> 1.1) + chef-zero (1.7.2) + hashie (~> 2.0) + json + mixlib-log (~> 1.3) + moneta (< 0.7.0) + rack childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) + coderay (1.1.0) + diff-lcs (1.2.5) erubis (2.7.0) - ffi (1.9.0) - highline (1.6.19) - i18n (0.6.5) + ffi (1.9.3) + hashie (2.0.5) + highline (1.6.20) + i18n (0.6.9) ipaddress (0.8.0) json (1.7.7) - librarian (0.1.0) + librarian (0.1.1) highline thor (~> 0.15) - librarian-chef (0.0.1) + librarian-chef (0.0.2) archive-tar-minitar (>= 0.5.2) chef (>= 0.10) librarian (~> 0.1.0) log4r (1.1.10) - mime-types (1.23) + method_source (0.8.2) + mime-types (1.25.1) mixlib-authentication (1.3.0) mixlib-log - mixlib-cli (1.3.0) - mixlib-config (1.1.2) + mixlib-cli (1.4.0) + mixlib-config (2.1.0) mixlib-log (1.6.0) - mixlib-shellout (1.2.0) + mixlib-shellout (1.3.0) + moneta (0.6.0) net-scp (1.1.2) net-ssh (>= 2.6.5) - net-ssh (2.6.8) + net-ssh (2.7.0) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) net-ssh-multi (1.1) net-ssh (>= 2.1.4) net-ssh-gateway (>= 0.99.0) - ohai (6.18.0) + ohai (6.20.0) ipaddress mixlib-cli mixlib-config mixlib-log mixlib-shellout - systemu + systemu (~> 2.5.2) yajl-ruby - rake (10.1.0) + pry (0.9.12.4) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + puma (1.6.3) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.1) rest-client (1.6.7) mime-types (>= 1.16) + slop (3.4.7) systemu (2.5.2) thor (0.18.1) - vagrant-librarian-chef (0.1.2) + vagrant-librarian-chef (0.1.4) librarian-chef - vagrant-omnibus (1.1.2) - yajl-ruby (1.1.0) + vagrant-omnibus (1.2.1) + yajl-ruby (1.2.0) PLATFORMS ruby diff --git a/README.md b/README.md index 27b0394..123e32b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # vagrant-cachier +[](http://badge.fury.io/rb/vagrant-cachier) [](https://www.gittip.com/fgrehm/) + A [Vagrant](http://www.vagrantup.com/) plugin that helps you reduce the amount of coffee you drink while waiting for boxes to be provisioned by sharing a common package cache among similiar VM instances. Kinda like [vagrant-apt_cache](https://github.com/avit/vagrant-apt_cache) @@ -9,7 +11,7 @@ multiple package managers and Linux distros. ## Installation -Make sure you have Vagrant 1.2+ and run: +Make sure you have Vagrant 1.4+ and run: ``` vagrant plugin install vagrant-cachier @@ -17,16 +19,26 @@ vagrant plugin install vagrant-cachier ## Quick start -The easiest way to set things up is just to enable [cache buckets auto detection](http://fgrehm.viewdocs.io/vagrant-cachier/usage) -from within your `Vagrantfile`: - ```ruby Vagrant.configure("2") do |config| config.vm.box = 'your-box' if Vagrant.has_plugin?("vagrant-cachier") - config.cache.auto_detect = true - # If you are using VirtualBox, you might want to enable NFS for shared folders - # config.cache.enable_nfs = true + # Configure cached packages to be shared between instances of the same base box. + # More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage + config.cache.scope = :box + + # If you are using VirtualBox, you might want to use that to enable NFS for + # shared folders. This is also very useful for vagrant-libvirt if you want + # bi-directional sync + config.cache.synced_folder_opts = { + type: :nfs, + # The nolock option can be useful for an NFSv3 client that wants to avoid the + # NLM sideband protocol. Without this option, apt-get might hang if it tries + # to lock files needed for /var/cache/* operations. All of this can be avoided + # by using NFSv4 everywhere. Please note that the tcp option is not the default. + mount_options: ['rw', 'vers=3', 'tcp', 'nolock'] + } + # For more information please check http://docs.vagrantup.com/v2/synced-folders/basic_usage.html end end ``` @@ -35,12 +47,17 @@ For more information please read the documentation available at http://fgrehm.viewdocs.io/vagrant-cachier. -## Compatible providers +## Providers that are known to work * Vagrant's built in VirtualBox provider * [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc) * [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See [GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info) +* [docker-provider](https://github.com/fgrehm/docker-provider) +* _[Let me know if it is compatible with other providers!](https://github.com/fgrehm/vagrant-cachier/issues/new)_ + +_Please note that as of v0.6.0 the plugin will automatically disable any +previously defined configs for [cloud providers](lib/vagrant-cachier/plugin.rb#L19-22)_ ## Contributing @@ -50,5 +67,3 @@ http://fgrehm.viewdocs.io/vagrant-cachier. 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request - -[](https://bitdeli.com/free "Bitdeli Badge") diff --git a/development/Cheffile.lock b/development/Cheffile.lock index 27492b3..2c2b9d6 100644 --- a/development/Cheffile.lock +++ b/development/Cheffile.lock @@ -1,11 +1,7 @@ SITE remote: http://community.opscode.com/api/v1 specs: - chef_handler (1.1.4) - java (1.12.0) - windows (>= 0.0.0) - windows (1.10.0) - chef_handler (>= 0.0.0) + java (1.19.2) DEPENDENCIES java (>= 0) diff --git a/development/Vagrantfile b/development/Vagrantfile index 0d33187..122ac0c 100644 --- a/development/Vagrantfile +++ b/development/Vagrantfile @@ -12,116 +12,126 @@ Vagrant.configure("2") do |config| config.cache.scope = :machine config.cache.auto_detect = true - config.cache.enable_nfs = true + config.cache.synced_folder_opts = { type: :nfs } - config.omnibus.chef_version = :latest - config.vm.provision :chef_solo do |chef| - chef.add_recipe "java::oracle" - chef.json = { - :java => { - :oracle => { - :accept_oracle_download_terms => true - } - } - } + config.vm.provider :virtualbox do |vb| + vb.customize [ "modifyvm", :id, "--memory", 256, "--cpus", "1" ] end - # Installs RVM - config.vm.provision :shell, inline: ' - if ! [ -d /home/vagrant/.rvm ]; then - HOME=/home/vagrant su -p vagrant -l -c "curl -L https://get.rvm.io | bash -s stable" - fi - ' - - # Here we have the RVM cache bucket configured, so we install 2.0.0 - config.vm.provision :shell, inline: ' - if ! [ -d /home/vagrant/.rvm/rubies/ruby-1.9.3* ]; then - HOME=/home/vagrant su -p vagrant -l -c "rvm install 1.9.3 && rvm use 1.9.3 --default" - fi - ' - - config.vm.provision :shell, inline: ' - if ! [ -d /home/vagrant/.nvm ]; then - apt-get install git -y - HOME=/home/vagrant su -p vagrant -l -c " - curl https://raw.github.com/creationix/nvm/master/install.sh | sh - " - fi - ' - - config.vm.provision :shell, inline: ' - if ! [ -d /home/vagrant/.nvm/v0.10* ]; then - HOME=/home/vagrant su -p vagrant -l -c " - nvm install 0.10 - nvm alias default 0.10 - " - fi - ' - configure_private_network = lambda do |node, suffix| node.vm.network :private_network, ip: "192.168.50.#{suffix}" end - debian_like_configs = lambda do |debian| - # Here we have the RubyGems cache bucket configured to the right path, so we - # bundle the project - debian.vm.provision :shell, inline: ' - sudo apt-get install -y git php5-cli - HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle" + initial_debian_setup = lambda do |debian, git_pkg = 'git'| + debian.vm.provision :shell, inline: "apt-get update && apt-get install -y #{git_pkg} php5-cli curl wget htop" + end + + install_nvm_and_rvm = lambda do |node| + # Installs RVM + node.vm.provision :shell, inline: ' + if ! [ -d /home/vagrant/.rvm ]; then + HOME=/home/vagrant su -p vagrant -l -c "curl -L https://get.rvm.io | bash -s stable" + fi + ' + + # Here we have the RVM cache bucket configured, so we install 2.0.0 + node.vm.provision :shell, inline: ' + if ! [ -d /home/vagrant/.rvm/rubies/ruby-2.0.0* ]; then + HOME=/home/vagrant su -p vagrant -l -c "rvm install 2.0.0 && rvm use 2.0.0 --default" + fi + ' + + node.vm.provision :shell, inline: ' + if ! [ -d /home/vagrant/.nvm ]; then + apt-get install git -y + HOME=/home/vagrant su -p vagrant -l -c " + curl https://raw.github.com/creationix/nvm/master/install.sh | sh + " + fi + ' + + node.vm.provision :shell, inline: ' + if ! [ -d /home/vagrant/.nvm/v0.10* ]; then + HOME=/home/vagrant su -p vagrant -l -c " + nvm install 0.10 + nvm alias default 0.10 + " + fi ' end config.vm.define :ubuntu do |ubuntu| ubuntu.vm.box = "quantal64" - debian_like_configs.call ubuntu configure_private_network.call ubuntu, 10 + + initial_debian_setup.call(ubuntu) + install_nvm_and_rvm.call(ubuntu) + + ubuntu.omnibus.chef_version = :latest + ubuntu.vm.provision :chef_solo do |chef| + chef.add_recipe "java::oracle" + chef.json = { + :java => { + :oracle => { + :accept_oracle_download_terms => true + } + } + } + end end config.vm.define :lucid do |lucid| lucid.vm.box = "lucid64" - debian_like_configs.call lucid + # Disable NFS + lucid.cache.synced_folder_opts = { } configure_private_network.call lucid, 11 + + initial_debian_setup.call(lucid, 'git-core') + install_nvm_and_rvm.call(lucid) end config.vm.define :debian do |debian| debian.vm.box = "squeeze64" debian.vm.box_url = 'http://f.willianfernandes.com.br/vagrant-boxes/DebianSqueeze64.box' - debian_like_configs.call debian configure_private_network.call debian, 12 + + initial_debian_setup.call(debian) + install_nvm_and_rvm.call(debian) end config.vm.define :centos do |centos| centos.vm.box = 'centos6_64' centos.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box' configure_private_network.call centos, 13 - # Here we have the RubyGems cache bucket configured to the right path, so we - # bundle the project + centos.vm.provision :shell, inline: ' - yum install -y libffi-devel ruby-devel git - HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' + ( + mkdir -p /tmp/epel + cd /tmp/epel + wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm + wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm + sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm + ) + yum install -y libffi-devel ruby-devel git + ' + centos.vm.provision :shell, inline: 'gem install bundler' end config.vm.define :arch do |arch| arch.vm.box = 'arch64' - arch.vm.box_url = 'http://vagrant.pouss.in/archlinux_2012-07-02.box' - configure_private_network.call arch, 14 - arch.vm.provision :shell, inline: ' - pacman -Syu --noconfirm libffi git - HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' + arch.vm.box_url = 'https://dl.dropboxusercontent.com/u/6750592/Arch_Linux_2013.11_x64.box' + # Disable NFS + arch.cache.synced_folder_opts = { } + + arch.vm.provision :shell, inline: 'pacman -Syu --noconfirm libffi git ruby && gem install bundler' end - # Please note that we are not able to install chef on the VM, so when bringing - # this up we should always pass in `--provision-with=shell` - # - # TODO: Find out how to install chef on this or other box or find one that has - # it pre installed config.vm.define :opensuse do |suse| suse.vm.box = 'opensuse-12' suse.vm.box_url = 'http://sourceforge.net/projects/opensusevagrant/files/12.3/opensuse-12.3-64.box/download' - configure_private_network.call suse, 15 - suse.cache.enable_nfs = false - # This seems to not be working - suse.omnibus.chef_version = nil + # Disable NFS + suse.cache.synced_folder_opts = { } + suse.vm.provision :shell, inline: 'time zypper install -y git' end end diff --git a/docs/buckets/apt-lists.md b/docs/buckets/apt-lists.md new file mode 100644 index 0000000..228ca15 --- /dev/null +++ b/docs/buckets/apt-lists.md @@ -0,0 +1,18 @@ +# APT lists + +Used by Debian-like Linux distros, will get configured under guest's `/var/lib/apt/lists`. + +As explained on [Wikipedia](http://en.wikipedia.org/wiki/Advanced_Packaging_Tool#Files), +`/var/lib/apt/lists` is the "storage area for state information for each package +resource specified in sources.list". By enabling this bucket, `apt` will be able +to install cached packages without hitting the remote repositories for the main +package lists, [being particularly useful when developing offline](https://github.com/fgrehm/vagrant-cachier/pull/84#issue-27311414). + +To manually enable it: + +```ruby +Vagrant.configure("2") do |config| + config.vm.box = 'some-debian-box' + config.cache.enable :apt_lists +end +``` diff --git a/docs/how-does-it-work.md b/docs/how-does-it-work.md index 80a8f5d..b357d89 100644 --- a/docs/how-does-it-work.md +++ b/docs/how-does-it-work.md @@ -20,12 +20,11 @@ _as part of_ the boot process (synced folders are actually `lxc-start` parameter and as of now we are not able to get some information that this plugin requires about the guest machine / container before it is actually up and running. -Under the hood, the plugin will monkey patch `Vagrant::Builtin::Provision` and -will set things up for each configured cache bucket _before and after_ running each -defined provisioner. Before halting the machine, it will also revert the changes -required to set things up by hooking into calls to `Vagrant::Builtin::GracefulHalt` -so that you can repackage the machine for others to use without requiring users to -install the plugin as well. +Under the hood, the plugin will hook into Vagrant in order to set things up for each +configured cache bucket _before and after_ running each defined provisioner. Before +halting the machine, it will also revert the changes required to set things up by +hooking into calls to `Vagrant::Builtin::GracefulHalt` so that you can repackage +the machine for others to use without requiring users to install the plugin as well. Please keep in mind that this plugin won't do magic, if you are compiling things during provisioning or manually downloading packages outside of a bucket you diff --git a/docs/index.md b/docs/index.md index f149c4d..c3d0507 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,7 +9,7 @@ multiple package managers and Linux distros. ## Installation -Make sure you have Vagrant 1.2+ and run: +Make sure you have Vagrant 1.4+ and run: ``` vagrant plugin install vagrant-cachier @@ -24,9 +24,21 @@ from within your `Vagrantfile`: Vagrant.configure("2") do |config| config.vm.box = 'your-box' if Vagrant.has_plugin?("vagrant-cachier") - config.cache.auto_detect = true - # If you are using VirtualBox, you might want to enable NFS for shared folders - # config.cache.enable_nfs = true + # Configure cached packages to be shared between instances of the same base box. + # More info on the "Usage" link above + config.cache.scope = :box + + # If you are using VirtualBox, you might want to use that to enable NFS for + # shared folders. This is also very useful for vagrant-libvirt if you want + # bi-directional sync + config.cache.synced_folder_opts = { + type: :nfs, + # The nolock option can be useful for an NFSv3 client that wants to avoid the + # NLM sideband protocol. Without this option, apt-get might hang if it tries + # to lock files needed for /var/cache/* operations. All of this can be avoided + # by using NFSv4 everywhere. Please note that the tcp option is not the default. + mount_options: ['rw', 'vers=3', 'tcp', 'nolock'] + } end end ``` @@ -34,12 +46,17 @@ end For more information please check out the links on the menu above. -## Compatible providers +## Providers that are known to work * Vagrant's built in VirtualBox provider * [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc) * [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See [GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info) +* [vagrant-libvirt](https://github.com/pradels/vagrant-libvirt) +* [vagrant-kvm](https://github.com/adrahon/vagrant-kvm) + +_Please note that as of v0.6.0 the plugin will automatically disable any +previously defined configs for [cloud providers](lib/vagrant-cachier/plugin.rb#L19-22)_ ## Contributing diff --git a/docs/template.html b/docs/template.html index ac464ae..e26d63c 100644 --- a/docs/template.html +++ b/docs/template.html @@ -83,6 +83,7 @@ Available Buckets