vagrant-cachier 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 447f8c66ad65b17a8bc2cc5a63b238bc1879868a
4
- data.tar.gz: a3f75f32e121e33d545a5c5f3cc0c6fee5126462
3
+ metadata.gz: 8e3d1a6bde8fed89429d000fe1cb4ad3d966873c
4
+ data.tar.gz: da33a199d777158597f0aa29df079eb63f7909b8
5
5
  SHA512:
6
- metadata.gz: 092fae1c133849f86db12eb0f0b05f29d11d74b43b58bba425993ccddda8fc05fc4118d26ea2b66822eb0147df7a47523706db482ee1fd859d1bb9b4ce47e627
7
- data.tar.gz: 8bdefb1e24bbb057f98a2c21f6bb0d22c55bfc7decf5af34dc910b4e90599380d2bcc61520668bcaa5c16faf1ea9444a3102662b5f6ac374101e68c67889e070
6
+ metadata.gz: 91ff3706421615c7f68d1fafa796ee0e9fa58ae2eee63aa35a4e02f49b73be7a8c7266e72b467af91e2d98b323b6faafb87e9c5436e4710bc4a0ea641b4ed6da
7
+ data.tar.gz: 8f1533ddbe6be87b8fa7beacf54d3d3627abcf2d6b797a09fbcf2cee722e23a82d6a7f5c745adc29ec0f17ef8adcb2324bcaccef70d38cebd0028b817bf7e45a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.4.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.3...v0.4.0) (Oct 23, 2013)
2
+
3
+ FEATURES:
4
+
5
+ - Support for [npm](https://npmjs.org/) [GH-51]
6
+ - Support for [Composer](http://getcomposer.org/) [GH-48]
7
+ - Support for `apt-cacher-ng` [GH-30]
8
+
9
+ BUG FIXES:
10
+
11
+ - Allow halting nonresponsive machine when plugin is installed [GH-8]
12
+
1
13
  ## [0.3.3](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.2...v0.3.3) (Sep 11, 2013)
2
14
 
3
15
  BUG FIXES:
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  GIT
2
2
  remote: git://github.com/fgrehm/vagrant-global-status.git
3
- revision: 860a7ce70ff4596621af492e47eace5631f47324
3
+ revision: a0295400a0e47756cbcb8f97ed9f4449b1fb6b56
4
4
  specs:
5
- vagrant-global-status (0.1.0)
5
+ vagrant-global-status (0.1.1)
6
6
 
7
7
  GIT
8
8
  remote: git://github.com/fgrehm/vagrant-lxc.git
9
- revision: 5ae82681cdedaf2a6f778e005dd65014fc7c2cec
9
+ revision: 225af5622767059708278db29d42941e93d41994
10
10
  specs:
11
- vagrant-lxc (0.5.1.dev)
11
+ vagrant-lxc (0.6.4.dev)
12
12
 
13
13
  GIT
14
14
  remote: git://github.com/fgrehm/vagrant-pristine.git
15
- revision: 5c400d7850fc5f98d9601b59f4c3bd74818650de
15
+ revision: 4638491786943bfbf6f115b1fc379f069963fe46
16
16
  specs:
17
- vagrant-pristine (0.2.0)
17
+ vagrant-pristine (0.3.0)
18
18
 
19
19
  GIT
20
20
  remote: git://github.com/mitchellh/vagrant.git
21
- revision: 16002d03c07f842a23497543129fa99f40f2bbc0
21
+ revision: 57e95323b6600b146167f0f14f83b22dd31dd03f
22
22
  specs:
23
- vagrant (1.2.8.dev)
23
+ vagrant (1.3.6.dev)
24
24
  childprocess (~> 0.3.7)
25
25
  erubis (~> 2.7.0)
26
26
  i18n (~> 0.6.0)
@@ -31,7 +31,7 @@ GIT
31
31
  PATH
32
32
  remote: .
33
33
  specs:
34
- vagrant-cachier (0.3.3)
34
+ vagrant-cachier (0.4.0)
35
35
 
36
36
  GEM
37
37
  remote: https://rubygems.org/
@@ -56,7 +56,7 @@ GEM
56
56
  erubis (2.7.0)
57
57
  ffi (1.9.0)
58
58
  highline (1.6.19)
59
- i18n (0.6.4)
59
+ i18n (0.6.5)
60
60
  ipaddress (0.8.0)
61
61
  json (1.7.7)
62
62
  librarian (0.1.0)
@@ -97,7 +97,7 @@ GEM
97
97
  thor (0.18.1)
98
98
  vagrant-librarian-chef (0.1.2)
99
99
  librarian-chef
100
- vagrant-omnibus (1.1.0)
100
+ vagrant-omnibus (1.1.2)
101
101
  yajl-ruby (1.1.0)
102
102
 
103
103
  PLATFORMS
data/README.md CHANGED
@@ -208,6 +208,65 @@ folder under the result of running `rvm info` as the default SSH user (usualy
208
208
  it is already installed before enabling the bucket, otherwise you won't benefit
209
209
  from this plugin.
210
210
 
211
+ #### [npm](https://npmjs.org/)
212
+
213
+ ```ruby
214
+ Vagrant.configure("2") do |config|
215
+ config.vm.box = 'some-box-with-nodejs-installed'
216
+ config.cache.enable :npm
217
+ end
218
+ ```
219
+
220
+ Compatible with probably any type of linux guest distro, will hook into npm's
221
+ cache directory under the result of running `npm config get cache` as
222
+ the default SSH user (usually `vagrant`) on your guest.
223
+ If you use
224
+ [nvm](https://github.com/creationix/nvm) / [n](https://github.com/visionmedia/n)
225
+ on the guest machine, make sure it is already installed before enabling
226
+ the bucket, otherwise you won't benefit from this plugin.
227
+
228
+ #### [Composer](http://getcomposer.org/)
229
+
230
+ ```ruby
231
+ Vagrant.configure("2") do |config|
232
+ config.vm.box = 'some-box-with-php-installed'
233
+ config.cache.enable :composer
234
+ end
235
+ ```
236
+
237
+ Compatible with probably any type of linux guest distro, will cache guests'
238
+ `$HOME/.composer` if PHP is detected.
239
+
240
+ ##### APT-CACHER
241
+
242
+ ```ruby
243
+ Vagrant.configure("2") do |config|
244
+ config.vm.box = 'some-debian-box'
245
+ config.cache.enable :apt_cacher
246
+ end
247
+ ```
248
+
249
+ This is useful, if you are using containers inside your VMs, e.g VirtualBox -> LXC.
250
+ This would allow you to reuse packages without sharing folder inside VirtualBox. Only
251
+ works with NFS-shared folders (since `vboxsf` is enforcing `vagrant`-user and `apt-cacher`
252
+ is running under `apt-cacher-ng` user)
253
+
254
+ # install apt-cacher on (Host)-VM
255
+ $ sudo apt-get install apt-cacher-ng
256
+
257
+ # get the IP for eth0 interface
258
+ $ ifconfig eth0 |grep "inet addr"|awk '{print $2}' |cut -c6-20
259
+
260
+ # configure mirror on for your docker/LXC instances:
261
+ $ echo 'Acquire::http { Proxy "http://X.X.X.X:3142"; };' > /etc/apt/apt.conf.d/10mirror
262
+
263
+ # check, if working by tailing log on (Host)-VM, while installing packages on (Guest)-VMs
264
+ $ tail -f /var/log/apt-cacher-ng/apt-cacher.log
265
+
266
+
267
+ Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt-cacher-ng`.
268
+
269
+
211
270
  ## Finding out disk space used by buckets
212
271
 
213
272
  _TODO_
@@ -44,11 +44,29 @@ Vagrant.configure("2") do |config|
44
44
  fi
45
45
  '
46
46
 
47
+ config.vm.provision :shell, inline: '
48
+ if ! [ -d /home/vagrant/.nvm ]; then
49
+ apt-get install git -y
50
+ HOME=/home/vagrant su -p vagrant -l -c "
51
+ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
52
+ "
53
+ fi
54
+ '
55
+
56
+ config.vm.provision :shell, inline: '
57
+ if ! [ -d /home/vagrant/.nvm/v0.10* ]; then
58
+ HOME=/home/vagrant su -p vagrant -l -c "
59
+ nvm install 0.10
60
+ nvm alias default 0.10
61
+ "
62
+ fi
63
+ '
64
+
47
65
  debian_like_configs = lambda do |debian|
48
66
  # Here we have the RubyGems cache bucket configured to the right path, so we
49
67
  # bundle the project
50
68
  debian.vm.provision :shell, inline: '
51
- sudo apt-get install git -y
69
+ sudo apt-get install -y git php5-cli
52
70
  HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"
53
71
  '
54
72
  end
@@ -86,5 +104,4 @@ Vagrant.configure("2") do |config|
86
104
  pacman -Syu --noconfirm libffi git
87
105
  HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"'
88
106
  end
89
-
90
107
  end
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  module VagrantPlugins
2
4
  module Cachier
3
5
  class Action
@@ -8,29 +10,54 @@ module VagrantPlugins
8
10
  end
9
11
 
10
12
  def call(env)
11
- @env = env
13
+ @env = env
14
+ @machine = env[:machine]
12
15
 
13
- if env[:machine].state.id == :running && symlinks.any?
16
+ if symlinks.any?
14
17
  env[:ui].info I18n.t('vagrant_cachier.cleanup')
15
- symlinks.each do |symlink|
16
- remove_symlink symlink
18
+ if sshable?
19
+ symlinks.each do |symlink|
20
+ remove_symlink symlink
21
+ end
17
22
  end
18
23
 
19
- File.delete env[:machine].data_dir.join('cache_dirs').to_s
24
+ File.delete @machine.data_dir.join('cache_dirs').to_s
20
25
  end
21
26
 
22
27
  @app.call env
23
28
  end
24
29
 
30
+ def sshable?
31
+ return if @machine.state.id != :running
32
+
33
+ # By default Vagrant will keep trying [1] to ssh connect to the VM for
34
+ # a long and we've got to prevent that from happening, so we just wait
35
+ # a few seconds and assume that the VM is halted / unresponsive and we
36
+ # carry on if it times out.
37
+ # [1] - https://github.com/mitchellh/vagrant/blob/57e95323b6600b146167f0f14f83b22dd31dd03f/plugins/communicators/ssh/communicator.rb#L185-L200
38
+ begin
39
+ Timeout.timeout(35) do
40
+ while true
41
+ return true if @machine.communicate.ready?
42
+ sleep 0.5
43
+ end
44
+ end
45
+ rescue Timeout::Error
46
+ @env[:ui].warn(I18n.t('vagrant_cachier.unable_to_ssh'))
47
+ end
48
+
49
+ return false
50
+ end
51
+
25
52
  def symlinks
26
53
  # TODO: Check if file exists instead of a blank rescue
27
- @symlinks ||= @env[:machine].data_dir.join('cache_dirs').read.split rescue []
54
+ @symlinks ||= @machine.data_dir.join('cache_dirs').read.split rescue []
28
55
  end
29
56
 
30
57
  def remove_symlink(symlink)
31
- if @env[:machine].communicate.test("test -L #{symlink}")
58
+ if @machine.communicate.test("test -L #{symlink}")
32
59
  @logger.debug "Removing symlink for '#{symlink}'"
33
- @env[:machine].communicate.sudo("unlink #{symlink}")
60
+ @machine.communicate.sudo("unlink #{symlink}")
34
61
  end
35
62
  end
36
63
  end
@@ -15,12 +15,12 @@ module VagrantPlugins
15
15
  end
16
16
 
17
17
  def self.bucket_name
18
- # TODO: Handle MultiWord bucket classes
19
- self.name.split('::').last.downcase
18
+ class_name = self.name.split('::').last
19
+ class_name.scan(/[A-Z][a-z]*/).map{|x| x.downcase}.join("_")
20
20
  end
21
21
 
22
22
  def self.install(name, env, configs)
23
- bucket = const_get(name.to_s.capitalize)
23
+ bucket = const_get(name.to_s.split("_").map{|x| x.capitalize}.join(""))
24
24
  bucket.new(name, env, configs).install
25
25
  end
26
26
 
@@ -39,3 +39,6 @@ require_relative "bucket/gem"
39
39
  require_relative "bucket/pacman"
40
40
  require_relative "bucket/yum"
41
41
  require_relative "bucket/rvm"
42
+ require_relative "bucket/apt_cacher"
43
+ require_relative "bucket/composer"
44
+ require_relative "bucket/npm"
@@ -0,0 +1,39 @@
1
+ # Apt-Cacher NG is a caching proxy for software packages which are downloaded by
2
+ # Unix/Linux system distribution mechanisms from mirror servers accessible via HTTP.
3
+ module VagrantPlugins
4
+ module Cachier
5
+ class Bucket
6
+ class AptCacher < Bucket
7
+ def self.capability
8
+ :apt_cacher_dir
9
+ end
10
+
11
+ def install
12
+ machine = @env[:machine]
13
+ guest = machine.guest
14
+
15
+ if guest.capability?(:apt_cacher_dir)
16
+ if machine.config.cache.enable_nfs
17
+ guest_path = guest.capability(:apt_cacher_dir)
18
+
19
+ @env[:cache_dirs] << guest_path
20
+
21
+ machine.communicate.tap do |comm|
22
+ comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
23
+ unless comm.test("test -L #{guest_path}")
24
+ comm.sudo("rm -rf #{guest_path}")
25
+ comm.sudo("mkdir -p `dirname #{guest_path}`")
26
+ comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
27
+ end
28
+ end
29
+ else
30
+ @env[:ui].info I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher')
31
+ end
32
+ else
33
+ @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-cacher')
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ module VagrantPlugins
2
+ module Cachier
3
+ class Bucket
4
+ class Composer < Bucket
5
+ def self.capability
6
+ :composer_path
7
+ end
8
+
9
+ def install
10
+ machine = @env[:machine]
11
+ guest = machine.guest
12
+
13
+ if guest.capability?(:composer_path)
14
+ if composer_path = guest.capability(:composer_path)
15
+ bucket_path = "/tmp/vagrant-cache/#{@name}"
16
+ @env[:cache_dirs] << composer_path
17
+
18
+ machine.communicate.tap do |comm|
19
+ comm.execute("mkdir -p #{bucket_path}")
20
+
21
+ unless comm.test("test -L #{composer_path}")
22
+ comm.sudo("rm -rf #{composer_path}")
23
+ comm.sudo("ln -s #{bucket_path} #{composer_path}")
24
+ end
25
+ end
26
+ end
27
+ else
28
+ @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ module VagrantPlugins
2
+ module Cachier
3
+ class Bucket
4
+ class Npm < Bucket
5
+ def self.capability
6
+ :npm_cache_dir
7
+ end
8
+
9
+ def install
10
+ machine = @env[:machine]
11
+ guest = machine.guest
12
+
13
+ if guest.capability?(:npm_cache_dir)
14
+ guest_path = guest.capability(:npm_cache_dir)
15
+
16
+ @env[:cache_dirs] << guest_path
17
+
18
+ machine.communicate.tap do |comm|
19
+ comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
20
+ unless comm.test("test -L #{guest_path}")
21
+ comm.execute("rm -rf #{guest_path}")
22
+ comm.execute("mkdir -p `dirname #{guest_path}`")
23
+ comm.execute("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
24
+ end
25
+ end
26
+ else
27
+ @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'npm')
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module Cachier
3
+ module Cap
4
+ module Debian
5
+ module AptCacherDir
6
+ def self.apt_cacher_dir(machine)
7
+ # cat /etc/apt-cacher-ng/acng.conf |grep CacheDir
8
+ '/var/cache/apt-cacher-ng'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Cachier
3
+ module Cap
4
+ module Linux
5
+ module ComposerPath
6
+ def self.composer_path(machine)
7
+ composer_path = nil
8
+ machine.communicate.tap do |comm|
9
+ return unless comm.test('which php')
10
+ comm.execute 'echo $HOME' do |buffer, output|
11
+ composer_path = output.chomp if buffer == :stdout
12
+ end
13
+ end
14
+ return "#{composer_path}/.composer"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Cachier
3
+ module Cap
4
+ module Linux
5
+ module NpmCacheDir
6
+ def self.npm_cache_dir(machine)
7
+ npm_cache_dir = nil
8
+ machine.communicate.tap do |comm|
9
+ return unless comm.test('which npm')
10
+ comm.execute 'npm config get cache' do |buffer, output|
11
+ npm_cache_dir = output.chomp if buffer == :stdout
12
+ end
13
+ end
14
+ return npm_cache_dir
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -26,16 +26,31 @@ module VagrantPlugins
26
26
  Cap::Linux::RvmPath
27
27
  end
28
28
 
29
+ guest_capability 'linux', 'composer_path' do
30
+ require_relative 'cap/linux/composer_path'
31
+ Cap::Linux::ComposerPath
32
+ end
33
+
29
34
  guest_capability 'linux', 'chef_file_cache_path' do
30
35
  require_relative 'cap/linux/chef_file_cache_path'
31
36
  Cap::Linux::ChefFileCachePath
32
37
  end
33
38
 
39
+ guest_capability 'linux', 'npm_cache_dir' do
40
+ require_relative 'cap/linux/npm_cache_dir'
41
+ Cap::Linux::NpmCacheDir
42
+ end
43
+
34
44
  guest_capability 'debian', 'apt_cache_dir' do
35
45
  require_relative 'cap/debian/apt_cache_dir'
36
46
  Cap::Debian::AptCacheDir
37
47
  end
38
48
 
49
+ guest_capability 'debian', 'apt_cacher_dir' do
50
+ require_relative 'cap/debian/apt_cacher_dir'
51
+ Cap::Debian::AptCacherDir
52
+ end
53
+
39
54
  guest_capability 'redhat', 'yum_cache_dir' do
40
55
  require_relative 'cap/redhat/yum_cache_dir'
41
56
  Cap::RedHat::YumCacheDir
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Cachier
3
- VERSION = "0.3.3"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -6,11 +6,16 @@ en:
6
6
  Skipping %{bucket} cache bucket as the guest machine does not support it
7
7
  unknown_cache_scope: |-
8
8
  Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed})
9
+ nfs_required: |-
10
+ The '%{bucket}' cache bucket requires NFS to be enabled, please add
11
+ `config.cache.enable_nfs = true` to your Vagrantfile.
9
12
  will_fix_machine_cache_dir: |-
10
13
  A vagrant-cachier provider specific cache dir was found under
11
14
  '%{current_path}' and it will be moved to
12
15
  '%{new_path}' as it is the new path for keeping machine
13
16
  scoped cache dirs starting with the 0.3.0 version of the plugin.
17
+ unable_to_ssh: |-
18
+ vagrant-cachier was unable to SSH into the VM to remove symlinks!
14
19
  vagrant:
15
20
  errors:
16
21
  multiple_provider_specific_cache_dirs_found: |-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-cachier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rehm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Speed up vagrant boxes provisioning
14
14
  email:
@@ -32,15 +32,21 @@ files:
32
32
  - lib/vagrant-cachier/action/ensure_single_cache_root.rb
33
33
  - lib/vagrant-cachier/bucket.rb
34
34
  - lib/vagrant-cachier/bucket/apt.rb
35
+ - lib/vagrant-cachier/bucket/apt_cacher.rb
35
36
  - lib/vagrant-cachier/bucket/chef.rb
37
+ - lib/vagrant-cachier/bucket/composer.rb
36
38
  - lib/vagrant-cachier/bucket/gem.rb
39
+ - lib/vagrant-cachier/bucket/npm.rb
37
40
  - lib/vagrant-cachier/bucket/pacman.rb
38
41
  - lib/vagrant-cachier/bucket/rvm.rb
39
42
  - lib/vagrant-cachier/bucket/yum.rb
40
43
  - lib/vagrant-cachier/cap/arch/pacman_cache_dir.rb
41
44
  - lib/vagrant-cachier/cap/debian/apt_cache_dir.rb
45
+ - lib/vagrant-cachier/cap/debian/apt_cacher_dir.rb
42
46
  - lib/vagrant-cachier/cap/linux/chef_file_cache_path.rb
47
+ - lib/vagrant-cachier/cap/linux/composer_path.rb
43
48
  - lib/vagrant-cachier/cap/linux/gemdir.rb
49
+ - lib/vagrant-cachier/cap/linux/npm_cache_dir.rb
44
50
  - lib/vagrant-cachier/cap/linux/rvm_path.rb
45
51
  - lib/vagrant-cachier/cap/redhat/yum_cache_dir.rb
46
52
  - lib/vagrant-cachier/config.rb
@@ -76,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
82
  version: '0'
77
83
  requirements: []
78
84
  rubyforge_project:
79
- rubygems_version: 2.0.7
85
+ rubygems_version: 2.1.5
80
86
  signing_key:
81
87
  specification_version: 4
82
88
  summary: Speed up vagrant boxes provisioning