vagrant-cachier 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -280
- data/development/Vagrantfile +1 -2
- data/docs/benchmarks.md +28 -0
- data/docs/buckets/apt-cacher.md +30 -0
- data/docs/buckets/apt.md +17 -0
- data/docs/buckets/chef.md +13 -0
- data/docs/buckets/composer.md +13 -0
- data/docs/buckets/npm.md +18 -0
- data/docs/buckets/pacman.md +12 -0
- data/docs/buckets/rubygems.md +22 -0
- data/docs/buckets/rvm.md +59 -0
- data/docs/buckets/yum.md +14 -0
- data/docs/buckets/zypper.md +14 -0
- data/docs/development.md +64 -0
- data/docs/how-does-it-work.md +32 -0
- data/docs/index.md +49 -0
- data/docs/template.html +137 -0
- data/docs/usage.md +99 -0
- data/lib/vagrant-cachier/provision_ext.rb +6 -2
- data/lib/vagrant-cachier/version.rb +1 -1
- data/spec/acceptance/fixtures/auto-detect-with-provisioning.rb +2 -1
- data/spec/acceptance/fixtures/auto-detect.rb +2 -1
- data/spec/acceptance/fixtures/no-cachier-simple.rb +2 -1
- data/spec/acceptance/fixtures/no-cachier-with-provisioning.rb +2 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6401dbe459feafa1b357a42a6bfa34220d3fa4a0
|
4
|
+
data.tar.gz: 7bbc8643bfe247c356819fd34476165675555bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fac081741ef0c1678cdf85e15c30beac681f319444ed2ee14902735866f647a570398fe76b902db7754474cff18a127867995af23d3d565de089d6b743c54494
|
7
|
+
data.tar.gz: 005f3712fc40ed86c7b0d7509a6d8056dbf47e3f3235d8dd12c83061a2b8cd68cdf3356a044a822132458b2919b595e6d5c0af5f8a2aad1fbbd44a31199fa46d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [0.5.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.0...v0.5.1) (Dec 20, 2013)
|
2
|
+
|
3
|
+
BUG FIXES:
|
4
|
+
|
5
|
+
- Fix NFS support for Vagrant 1.4+ [GH-67]
|
6
|
+
|
1
7
|
## [0.5.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.1...v0.5.0) (Nov 8, 2013)
|
2
8
|
|
3
9
|
FEATURES:
|
@@ -11,7 +17,6 @@ BUG FIXES:
|
|
11
17
|
- Do not attempt to configure apt-cacher-ng bucket if it is not installed on guest
|
12
18
|
machine.
|
13
19
|
|
14
|
-
|
15
20
|
## [0.4.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.3...v0.4.0) (Oct 23, 2013)
|
16
21
|
|
17
22
|
FEATURES:
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,9 +15,9 @@ Make sure you have Vagrant 1.2+ and run:
|
|
15
15
|
vagrant plugin install vagrant-cachier
|
16
16
|
```
|
17
17
|
|
18
|
-
##
|
18
|
+
## Quick start
|
19
19
|
|
20
|
-
The easiest way to set things up is just to enable [cache buckets auto detection](
|
20
|
+
The easiest way to set things up is just to enable [cache buckets auto detection](http://fgrehm.viewdocs.io/vagrant-cachier/usage)
|
21
21
|
from within your `Vagrantfile`:
|
22
22
|
|
23
23
|
```ruby
|
@@ -29,7 +29,8 @@ Vagrant.configure("2") do |config|
|
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
32
|
-
For more information
|
32
|
+
For more information please read the documentation available at
|
33
|
+
http://fgrehm.viewdocs.io/vagrant-cachier.
|
33
34
|
|
34
35
|
|
35
36
|
## Compatible providers
|
@@ -39,283 +40,6 @@ For more information about available buckets, please see the [configuration sect
|
|
39
40
|
* [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See
|
40
41
|
[GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info)
|
41
42
|
|
42
|
-
## How does it work?
|
43
|
-
|
44
|
-
Right now the plugin does not make any assumptions for you and you have to
|
45
|
-
configure things properly from your `Vagrantfile`. Please have a look at
|
46
|
-
the [available cache buckets](#available-cache-buckets) section below for more
|
47
|
-
information.
|
48
|
-
|
49
|
-
Under the hood, the plugin will monkey patch `Vagrant::Builtin::Provision` and
|
50
|
-
will set things up for each configured cache bucket before running each defined
|
51
|
-
provisioner and after all provisioners are done. Before halting the machine,
|
52
|
-
it will revert the changes required to set things up by hooking into calls to
|
53
|
-
`Vagrant::Builtin::GracefulHalt` so that you can repackage the machine for others
|
54
|
-
to use without requiring users to install the plugin as well.
|
55
|
-
|
56
|
-
Cache buckets will be available from `/tmp/vagrant-cachier` on your guest and
|
57
|
-
the appropriate folders will get symlinked to the right path _after_ the machine is
|
58
|
-
up but _right before_ it gets provisioned. We _could_ potentially do it on one go
|
59
|
-
and share bucket's folders directly to the right path if we were only using VirtualBox
|
60
|
-
since it shares folders _after_ booting the machine, but the LXC provider does that
|
61
|
-
_as part of_ the boot process (shared folders are actually `lxc-start` parameters)
|
62
|
-
and as of now we are not able to get some information that this plugin requires
|
63
|
-
about the guest machine before it is actually up and running.
|
64
|
-
|
65
|
-
Please keep in mind that this plugin won't do magic, if you are compiling things
|
66
|
-
during provisioning or manually downloading packages that does not fit into a
|
67
|
-
"cache bucket" you won't see that much of improvement.
|
68
|
-
|
69
|
-
|
70
|
-
## Benchmarks / shameless plug
|
71
|
-
|
72
|
-
Please have a look at [this blog post](http://fabiorehm.com/blog/2013/05/24/stop-wasting-bandwidth-with-vagrant-cachier#show_me_the_numbers)
|
73
|
-
for the numbers I've got down here.
|
74
|
-
|
75
|
-
|
76
|
-
## Configurations
|
77
|
-
|
78
|
-
### Auto detect supported cache buckets
|
79
|
-
|
80
|
-
As described on the usage section above, you can enable automatic detection of
|
81
|
-
supported [cache "buckets"](#available-cache-buckets) by adding the code below to
|
82
|
-
your `Vagrantfile`:
|
83
|
-
|
84
|
-
```ruby
|
85
|
-
Vagrant.configure("2") do |config|
|
86
|
-
# ...
|
87
|
-
config.cache.auto_detect = true
|
88
|
-
end
|
89
|
-
```
|
90
|
-
|
91
|
-
This will make vagrant-cachier do its best to find out what is supported on the
|
92
|
-
guest machine and will set buckets accordingly.
|
93
|
-
|
94
|
-
### Cache scope
|
95
|
-
|
96
|
-
By default downloaded packages will get stored on a folder scoped to base boxes
|
97
|
-
under your `$HOME/.vagrant.d/cache`. The idea is to leverage the cache by allowing
|
98
|
-
downloaded packages to be reused across projects. So, if your `Vagrantfile` has
|
99
|
-
something like:
|
100
|
-
|
101
|
-
```ruby
|
102
|
-
Vagrant.configure("2") do |config|
|
103
|
-
config.vm.box = 'some-box'
|
104
|
-
end
|
105
|
-
```
|
106
|
-
|
107
|
-
The cached files will be stored under `$HOME/.vagrant.d/cache/some-box`.
|
108
|
-
|
109
|
-
If you are on a [multi VM environment](http://docs.vagrantup.com/v2/multi-machine/index.html),
|
110
|
-
there is a huge chance that you'll end up having issues by sharing the same bucket
|
111
|
-
across different machines. For example, if you `apt-get install` from two machines
|
112
|
-
at "almost the same time" you are probably going to hit a `SystemError: Failed to lock /var/cache/apt/archives/lock`.
|
113
|
-
To work around that, you can set the scope to be based on machines:
|
114
|
-
|
115
|
-
```ruby
|
116
|
-
Vagrant.configure("2") do |config|
|
117
|
-
config.vm.box = 'some-box'
|
118
|
-
config.cache.scope = :machine
|
119
|
-
end
|
120
|
-
```
|
121
|
-
|
122
|
-
This will tell vagrant-cachier to download packages to `.vagrant/machines/<machine-name>/cache`
|
123
|
-
on your current project directory.
|
124
|
-
|
125
|
-
|
126
|
-
### Available cache "buckets"
|
127
|
-
|
128
|
-
#### System package managers
|
129
|
-
|
130
|
-
##### APT
|
131
|
-
|
132
|
-
```ruby
|
133
|
-
Vagrant.configure("2") do |config|
|
134
|
-
config.vm.box = 'some-debian-box'
|
135
|
-
config.cache.enable :apt
|
136
|
-
end
|
137
|
-
```
|
138
|
-
|
139
|
-
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt/archives`.
|
140
|
-
|
141
|
-
_Please note that to avoid re-downloading packages, you should avoid `apt-get clean`
|
142
|
-
as much as possible in order to make a better use of the cache, even if you are
|
143
|
-
packaging a box_
|
144
|
-
|
145
|
-
##### Zypper
|
146
|
-
|
147
|
-
```ruby
|
148
|
-
Vagrant.configure("2") do |config|
|
149
|
-
config.vm.box = 'some-suse-box'
|
150
|
-
config.cache.enable :zypper
|
151
|
-
end
|
152
|
-
```
|
153
|
-
|
154
|
-
Used by SuSE guests, will get configured under guest's `/var/cache/zypp/packages`. It will
|
155
|
-
also [make sure](lib/vagrant-cachier/bucket/zypper.rb#L20) that `keep-packages` is enabled
|
156
|
-
for all repositories.
|
157
|
-
|
158
|
-
###### Yum
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
Vagrant.configure("2") do |config|
|
162
|
-
config.vm.box = 'some-centos-box'
|
163
|
-
config.cache.enable :yum
|
164
|
-
end
|
165
|
-
```
|
166
|
-
|
167
|
-
Used by CentOS guests, will get configured under guest's `/var/cache/yum`. It will
|
168
|
-
also [make sure](lib/vagrant-cachier/bucket/yum.rb#L20) that `keepcache` is set to
|
169
|
-
`1` on guest's `/etc/yum.conf`.
|
170
|
-
|
171
|
-
##### Pacman
|
172
|
-
|
173
|
-
```ruby
|
174
|
-
Vagrant.configure("2") do |config|
|
175
|
-
config.vm.box = 'some-arch-linux-box'
|
176
|
-
config.cache.enable :pacman
|
177
|
-
end
|
178
|
-
```
|
179
|
-
|
180
|
-
Used by Arch Linux, will get configured under guest's `/var/cache/pacman/pkg`.
|
181
|
-
|
182
|
-
#### Chef
|
183
|
-
|
184
|
-
```ruby
|
185
|
-
Vagrant.configure("2") do |config|
|
186
|
-
config.vm.box = 'some-box-using-chef-provisioner'
|
187
|
-
config.cache.enable :chef
|
188
|
-
end
|
189
|
-
```
|
190
|
-
|
191
|
-
When a Chef provisioner is detected, this bucket caches the default
|
192
|
-
`file_cache_path` directory, `/var/chef/cache`. Requires Vagrant 1.2.4+.
|
193
|
-
|
194
|
-
#### RubyGems
|
195
|
-
|
196
|
-
```ruby
|
197
|
-
Vagrant.configure("2") do |config|
|
198
|
-
config.vm.box = 'some-box-with-ruby-installed'
|
199
|
-
config.cache.enable :gem
|
200
|
-
end
|
201
|
-
```
|
202
|
-
|
203
|
-
Compatible with probably with any type of guest distro, will hook into the `cache`
|
204
|
-
folder under the result of running `gem env gemdir` as the default SSH user (usualy
|
205
|
-
`vagrant`) on your guest. If you use rbenv / rvm on the guest machine, make sure
|
206
|
-
it is already installed before enabling the bucket, otherwise you won't benefit
|
207
|
-
from this plugin.
|
208
|
-
|
209
|
-
#### RVM
|
210
|
-
|
211
|
-
```ruby
|
212
|
-
Vagrant.configure("2") do |config|
|
213
|
-
config.vm.box = 'some-box-with-rvm-installed'
|
214
|
-
config.cache.enable :rvm
|
215
|
-
end
|
216
|
-
```
|
217
|
-
|
218
|
-
Compatible with probably with any type of linux guest distro, will hook into the `cache`
|
219
|
-
folder under the result of running `rvm info` as the default SSH user (usualy
|
220
|
-
`vagrant`) on your guest. If you use rvm on the guest machine, make sure
|
221
|
-
it is already installed before enabling the bucket, otherwise you won't benefit
|
222
|
-
from this plugin.
|
223
|
-
|
224
|
-
#### [npm](https://npmjs.org/)
|
225
|
-
|
226
|
-
```ruby
|
227
|
-
Vagrant.configure("2") do |config|
|
228
|
-
config.vm.box = 'some-box-with-nodejs-installed'
|
229
|
-
config.cache.enable :npm
|
230
|
-
end
|
231
|
-
```
|
232
|
-
|
233
|
-
Compatible with probably any type of linux guest distro, will hook into npm's
|
234
|
-
cache directory under the result of running `npm config get cache` as
|
235
|
-
the default SSH user (usually `vagrant`) on your guest.
|
236
|
-
If you use
|
237
|
-
[nvm](https://github.com/creationix/nvm) / [n](https://github.com/visionmedia/n)
|
238
|
-
on the guest machine, make sure it is already installed before enabling
|
239
|
-
the bucket, otherwise you won't benefit from this plugin.
|
240
|
-
|
241
|
-
#### [Composer](http://getcomposer.org/)
|
242
|
-
|
243
|
-
```ruby
|
244
|
-
Vagrant.configure("2") do |config|
|
245
|
-
config.vm.box = 'some-box-with-php-installed'
|
246
|
-
config.cache.enable :composer
|
247
|
-
end
|
248
|
-
```
|
249
|
-
|
250
|
-
Compatible with probably any type of linux guest distro, will cache guests'
|
251
|
-
`$HOME/.composer` if PHP is detected.
|
252
|
-
|
253
|
-
##### APT-CACHER
|
254
|
-
|
255
|
-
```ruby
|
256
|
-
Vagrant.configure("2") do |config|
|
257
|
-
config.vm.box = 'some-debian-box'
|
258
|
-
config.cache.enable :apt_cacher
|
259
|
-
end
|
260
|
-
```
|
261
|
-
|
262
|
-
This is useful, if you are using containers inside your VMs, e.g VirtualBox -> LXC.
|
263
|
-
This would allow you to reuse packages without sharing folder inside VirtualBox. Only
|
264
|
-
works with NFS-shared folders (since `vboxsf` is enforcing `vagrant`-user and `apt-cacher`
|
265
|
-
is running under `apt-cacher-ng` user)
|
266
|
-
|
267
|
-
# install apt-cacher on (Host)-VM
|
268
|
-
$ sudo apt-get install apt-cacher-ng
|
269
|
-
|
270
|
-
# get the IP for eth0 interface
|
271
|
-
$ ifconfig eth0 |grep "inet addr"|awk '{print $2}' |cut -c6-20
|
272
|
-
|
273
|
-
# configure mirror on for your docker/LXC instances:
|
274
|
-
$ echo 'Acquire::http { Proxy "http://X.X.X.X:3142"; };' > /etc/apt/apt.conf.d/10mirror
|
275
|
-
|
276
|
-
# check, if working by tailing log on (Host)-VM, while installing packages on (Guest)-VMs
|
277
|
-
$ tail -f /var/log/apt-cacher-ng/apt-cacher.log
|
278
|
-
|
279
|
-
|
280
|
-
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt-cacher-ng`.
|
281
|
-
|
282
|
-
|
283
|
-
## Finding out disk space used by buckets
|
284
|
-
|
285
|
-
_TODO_
|
286
|
-
|
287
|
-
```shell
|
288
|
-
$ vagrant cache stats
|
289
|
-
```
|
290
|
-
|
291
|
-
|
292
|
-
## Cleaning up cache buckets
|
293
|
-
|
294
|
-
_TODO_
|
295
|
-
|
296
|
-
```shell
|
297
|
-
$ vagrant cache clean apt
|
298
|
-
```
|
299
|
-
|
300
|
-
|
301
|
-
## Development
|
302
|
-
|
303
|
-
If you want to install the plugin from sources:
|
304
|
-
|
305
|
-
```bash
|
306
|
-
git clone https://github.com/fgrehm/vagrant-cachier.git
|
307
|
-
cd vagrant-cachier
|
308
|
-
bundle install
|
309
|
-
bundle exec rake build
|
310
|
-
vagrant plugin install pkg/vagrant-cachier-VERSION.gem
|
311
|
-
```
|
312
|
-
|
313
|
-
There are also some [Bats](https://github.com/sstephenson/bats) tests that basically
|
314
|
-
acts as a [sanity check](spec/acceptance/sanity_check.bats) that you can run with
|
315
|
-
`bats spec/acceptance` in case you are planning to submit a Pull Request :) Just
|
316
|
-
keep in mind that it might take a while to run if you are using the default
|
317
|
-
VirtualBox provider.
|
318
|
-
|
319
43
|
|
320
44
|
## Contributing
|
321
45
|
|
@@ -324,3 +48,5 @@ VirtualBox provider.
|
|
324
48
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
325
49
|
4. Push to the branch (`git push origin my-new-feature`)
|
326
50
|
5. Create new Pull Request
|
51
|
+
|
52
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/fgrehm/vagrant-cachier/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
data/development/Vagrantfile
CHANGED
@@ -8,13 +8,12 @@ Vagrant.require_plugin 'vagrant-omnibus'
|
|
8
8
|
Vagrant.require_plugin 'vagrant-pristine'
|
9
9
|
|
10
10
|
Vagrant.configure("2") do |config|
|
11
|
-
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
|
11
|
+
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
|
12
12
|
|
13
13
|
config.cache.scope = :machine
|
14
14
|
config.cache.auto_detect = true
|
15
15
|
config.cache.enable_nfs = true
|
16
16
|
|
17
|
-
|
18
17
|
config.omnibus.chef_version = :latest
|
19
18
|
config.vm.provision :chef_solo do |chef|
|
20
19
|
chef.add_recipe "java::oracle"
|
data/docs/benchmarks.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Benchmarks
|
2
|
+
|
3
|
+
During the early days of this plugin, [@fgrehm](https://github.com/fgrehm) wrote
|
4
|
+
a [blog post](http://fabiorehm.com/blog/2013/05/24/stop-wasting-bandwidth-with-vagrant-cachier#show_me_the_numbers)
|
5
|
+
with some benchmarks on the time that was cut down by using the plugin. If you
|
6
|
+
are interested on the numbers only, the VMs tested were one of vagrant-lxc's
|
7
|
+
Ubuntu [dev boxes](https://github.com/fgrehm/vagrant-lxc/wiki/Development#using-virtualbox-for-development),
|
8
|
+
[rails-dev-box](https://github.com/rails/rails-dev-box), his own [rails-base-box](https://github.com/fgrehm/rails-base-box)
|
9
|
+
and Discourse's [dev box](https://github.com/discourse/discourse/blob/master/Vagrantfile)
|
10
|
+
|
11
|
+
| | First provision | Second provision | Diff. | APT cache |
|
12
|
+
| --- | :---: | :---: | :---: | :---: |
|
13
|
+
| rails-dev-box | 4m45s | 3m20s | ~29% | 66mb |
|
14
|
+
| rails-base-box | 11m56s | 7m54s | ~34% | 77mb |
|
15
|
+
| vagrant-lxc | 10m16s | 5m9s | ~50% | 124mb |
|
16
|
+
| discourse | 1m41s | 49s | ~51% | 62mb |
|
17
|
+
<br>
|
18
|
+
_Please note that the tests were made on May 24th 2013 and nowadays they might
|
19
|
+
be a bit different_
|
20
|
+
|
21
|
+
<br>
|
22
|
+
Some people have shared their numbers on Twitter and had experienced even better
|
23
|
+
results:
|
24
|
+
|
25
|
+
<blockquote><p>Holy cow... If you dig Vagrant, and like time - you need Vagrant Cachier. 60% speed increase for me. <a href="https://t.co/225jRH7bDa">https://t.co/225jRH7bDa</a> <a href="https://twitter.com/vagrantup">@vagrantup</a></p>— Chris Rickard (@chrisrickard) <a href="https://twitter.com/chrisrickard/statuses/400128294479081472">November 12, 2013</a></blockquote>
|
26
|
+
<blockquote><p>vagrant-cachier saved 3:20 off my <a href="https://twitter.com/search?q=%23vagrant&src=hash">#vagrant</a> <a href="https://twitter.com/search?q=%23provisioning&src=hash">#provisioning</a> <a href="http://t.co/VzRRu1QEwL">http://t.co/VzRRu1QEwL</a></p>— Joe Ferguson (@svpernova09) <a href="https://twitter.com/svpernova09/statuses/400040517943037952">November 11, 2013</a></blockquote>
|
27
|
+
<blockquote><p>Tested vagrant-cachier. Saved 60% of vagrant up time installing 10 rpms with chef. Pretty awesome. Check it out! <a href="https://t.co/HfbLJNP7GH">github.com/fgrehm/vagrant…</a></p>— Miguel. (@miguelcnf) <a href="https://twitter.com/miguelcnf/status/343757107058847746">June 9, 2013</a></blockquote>
|
28
|
+
<blockquote><p>vagrant-cachier took my vagrant spin up from 30 to 5 minutes and reduced my caffeine intake by 3 cups <a href="http://t.co/V0uYpr3U0y">http://t.co/V0uYpr3U0y</a></p>— Russell Cardullo (@russellcardullo) <a href="https://twitter.com/russellcardullo/statuses/343070870744494080">June 7, 2013</a></blockquote>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# APT-CACHER
|
2
|
+
|
3
|
+
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt-cacher-ng`
|
4
|
+
and only works with NFS-shared folders since `vboxsf` is enforcing `vagrant`-user and `apt-cacher`
|
5
|
+
is running under `apt-cacher-ng` user.
|
6
|
+
|
7
|
+
To manually enable it:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
Vagrant.configure("2") do |config|
|
11
|
+
config.vm.box = 'some-debian-box'
|
12
|
+
config.cache.enable :apt_cacher
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
One use case for this bucket is if you are using containers inside your VMs, e.g
|
17
|
+
VirtualBox -> LXC. This would allow you to reuse packages without sharing folder
|
18
|
+
inside VirtualBox:
|
19
|
+
|
20
|
+
# install apt-cacher on (Host)-VM
|
21
|
+
$ sudo apt-get install apt-cacher-ng
|
22
|
+
|
23
|
+
# get the IP for eth0 interface
|
24
|
+
$ ifconfig eth0 |grep "inet addr"|awk '{print $2}' |cut -c6-20
|
25
|
+
|
26
|
+
# configure mirror on for your docker/LXC instances:
|
27
|
+
$ echo 'Acquire::http { Proxy "http://X.X.X.X:3142"; };' > /etc/apt/apt.conf.d/10mirror
|
28
|
+
|
29
|
+
# check, if working by tailing log on (Host)-VM, while installing packages on (Guest)-VMs
|
30
|
+
$ tail -f /var/log/apt-cacher-ng/apt-cacher.log
|
data/docs/buckets/apt.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# APT
|
2
|
+
|
3
|
+
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt/archives`.
|
4
|
+
|
5
|
+
To manually enable it:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
Vagrant.configure("2") do |config|
|
9
|
+
config.vm.box = 'some-debian-box'
|
10
|
+
config.cache.enable :apt
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
_Please note that to avoid re-downloading packages, you should avoid `apt-get clean`
|
15
|
+
as much as possible in order to make a better use of the cache, even if you are
|
16
|
+
packaging a box since the downloaded packages are actually stored on the host
|
17
|
+
machine._
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Chef
|
2
|
+
|
3
|
+
When a Chef provisioner is detected, this bucket caches the default
|
4
|
+
`file_cache_path` directory, `/var/chef/cache`. Requires Vagrant 1.2.4+.
|
5
|
+
|
6
|
+
To manually enable it:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
Vagrant.configure("2") do |config|
|
10
|
+
config.vm.box = 'some-box-using-chef-provisioner'
|
11
|
+
config.cache.enable :chef
|
12
|
+
end
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# [Composer](http://getcomposer.org/)
|
2
|
+
|
3
|
+
Compatible with probably any type of linux guest distro, will cache guests'
|
4
|
+
`$HOME/.composer` if PHP is detected.
|
5
|
+
|
6
|
+
To manually enable it:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
Vagrant.configure("2") do |config|
|
10
|
+
config.vm.box = 'some-box-with-php-installed'
|
11
|
+
config.cache.enable :composer
|
12
|
+
end
|
13
|
+
```
|
data/docs/buckets/npm.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# [npm](https://npmjs.org/)
|
2
|
+
|
3
|
+
Compatible with probably any type of linux guest distro, will hook into npm's
|
4
|
+
cache directory under the result of running `npm config get cache` as
|
5
|
+
the default SSH user (usually `vagrant`) on your guest.
|
6
|
+
|
7
|
+
To manually enable it:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
Vagrant.configure("2") do |config|
|
11
|
+
config.vm.box = 'some-box-with-nodejs-installed'
|
12
|
+
config.cache.enable :npm
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
If you use [nvm](https://github.com/creationix/nvm) / [n](https://github.com/visionmedia/n)
|
17
|
+
on the guest machine, make sure it is already installed before enabling
|
18
|
+
the bucket, otherwise you won't benefit from this plugin.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# RubyGems
|
2
|
+
|
3
|
+
Compatible with probably with any type of guest distro, will hook into the `cache`
|
4
|
+
folder under the result of running `gem env gemdir` as the default SSH user (usualy
|
5
|
+
`vagrant`) on your guest. If you use rbenv / rvm on the guest machine, make sure
|
6
|
+
it is already installed before enabling the bucket, otherwise you won't benefit
|
7
|
+
from this plugin.
|
8
|
+
|
9
|
+
To manually enable it:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Vagrant.configure("2") do |config|
|
13
|
+
config.vm.box = 'some-box-with-ruby-installed'
|
14
|
+
config.cache.enable :gem
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
## Heads up about `bundle install --deployment`
|
19
|
+
|
20
|
+
Please note that when the `--deployment` flag is passed on to `bundle install`
|
21
|
+
your gems **will not be cached** since bundler ends up skipping the default gem
|
22
|
+
cache dir. For more information about this, please check [GH-62](https://github.com/fgrehm/vagrant-cachier/issues/62).
|
data/docs/buckets/rvm.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# [rvm](https://rvm.io/)
|
2
|
+
|
3
|
+
Compatible with probably with any type of linux guest distro, will hook into the
|
4
|
+
`cache` folder under the result of running rvm info as the default SSH user (usualy
|
5
|
+
`vagrant`) on your guest. If you use rvm on the guest machine, make sure it is
|
6
|
+
already installed before enabling the bucket, otherwise you won't benefit from
|
7
|
+
this plugin.
|
8
|
+
|
9
|
+
To manually enable it:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Vagrant.configure("2") do |config|
|
13
|
+
config.vm.box = 'some-box-with-rvm-installed'
|
14
|
+
config.cache.enable :gem
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
## Heads up!
|
19
|
+
|
20
|
+
If you are installing rvm, rubies and gems on a single provisioning step, **you
|
21
|
+
will not benefit from this bucket**. There is absolutely no way we can "magically"
|
22
|
+
hook into your provisioning scripts to configure things for leveraging the cache.
|
23
|
+
|
24
|
+
For instance, the following shell provisioner **will result in no package cached at
|
25
|
+
all**:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
config.vm.provision :shell, privileged: false, inline: %[
|
29
|
+
curl -L https://get.rvm.io | bash -s stable
|
30
|
+
rvm install 1.9.3
|
31
|
+
rvm use 1.9.3 --default
|
32
|
+
cd /path/to/project
|
33
|
+
bundle install
|
34
|
+
]
|
35
|
+
```
|
36
|
+
|
37
|
+
To work around that you can either configure things by hand on your provisioning
|
38
|
+
scripts or you can enable automatic bucket detection and split your scripts into
|
39
|
+
multiple stages:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# Install RVM so that Ruby tarballs are cached
|
43
|
+
config.vm.provision :shell, privileged: false, inline: %[
|
44
|
+
curl -L https://get.rvm.io | bash -s stable
|
45
|
+
]
|
46
|
+
|
47
|
+
# Install Ruby 1.9.3 making use of the RVM cache and configure the RubyGems
|
48
|
+
# cache afterwards
|
49
|
+
config.vm.provision :shell, privileged: false, inline: %[
|
50
|
+
rvm install 1.9.3
|
51
|
+
rvm use 1.9.3 --default
|
52
|
+
]
|
53
|
+
|
54
|
+
# Install gems making use of the RubyGems cache
|
55
|
+
config.vm.provision :shell, privileged: false, inline: %[
|
56
|
+
cd /path/to/project
|
57
|
+
bundle install
|
58
|
+
]
|
59
|
+
```
|
data/docs/buckets/yum.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Yum
|
2
|
+
|
3
|
+
Used by CentOS guests, will get configured under guest's `/var/cache/yum`. It will
|
4
|
+
also [make sure](lib/vagrant-cachier/bucket/yum.rb#L20) that `keepcache` is set to
|
5
|
+
`1` on guest's `/etc/yum.conf`.
|
6
|
+
|
7
|
+
To manually enable it:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
Vagrant.configure("2") do |config|
|
11
|
+
config.vm.box = 'some-centos-box'
|
12
|
+
config.cache.enable :yum
|
13
|
+
end
|
14
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Zypper
|
2
|
+
|
3
|
+
Used by SuSE guests, will get configured under guest's `/var/cache/zypp/packages`. It will
|
4
|
+
also [make sure](lib/vagrant-cachier/bucket/zypper.rb#L20) that `keep-packages` is enabled
|
5
|
+
for all repositories.
|
6
|
+
|
7
|
+
To manually enable it:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
Vagrant.configure("2") do |config|
|
11
|
+
config.vm.box = 'some-suse-box'
|
12
|
+
config.cache.enable :zypper
|
13
|
+
end
|
14
|
+
```
|
data/docs/development.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Development
|
2
|
+
|
3
|
+
## Installing from sources
|
4
|
+
|
5
|
+
If you want to install the plugin from sources:
|
6
|
+
|
7
|
+
```bash
|
8
|
+
git clone https://github.com/fgrehm/vagrant-cachier.git
|
9
|
+
cd vagrant-cachier
|
10
|
+
bundle install
|
11
|
+
bundle exec rake build
|
12
|
+
vagrant plugin install pkg/vagrant-cachier-VERSION.gem
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
## Sanity checks
|
17
|
+
|
18
|
+
While we don't get to implement some proper unit testing, there are some basic [Bats](https://github.com/sstephenson/bats)
|
19
|
+
tests that basically acts as a [sanity check](https://github.com/fgrehm/vagrant-cachier/blob/master/spec/acceptance/sanity_check.bats)
|
20
|
+
that you can run with `bats spec/acceptance` in case you are planning to submit a
|
21
|
+
Pull Request. Just keep in mind that it might take a while to run if you are
|
22
|
+
using the default VirtualBox provider.
|
23
|
+
|
24
|
+
|
25
|
+
## How to create a new bucket?
|
26
|
+
|
27
|
+
The concept of a cache _bucket_ is pretty easy to understand, we basically
|
28
|
+
symlink a folder under the guest's `/tmp/vagrant-cache` into the folder where
|
29
|
+
other tools keep downloaded packages. For example, in the case of the
|
30
|
+
[apt bucket](buckets/apt), we symlink `/var/cache/apt/archives` to
|
31
|
+
`/tmp/vagrant-cache/apt` so that `.deb` packages downloaded with `apt-get install`
|
32
|
+
can be reused when bringing machines up from scratch.
|
33
|
+
|
34
|
+
If you want to see some other package manager supported, you'll first need to
|
35
|
+
know if it has some sort of caching in place, where does it get stored and if
|
36
|
+
it needs some extra configuration. For some managers that path will be fixed
|
37
|
+
(like the canonical apt bucket), for others you might need to read some
|
38
|
+
configuration by [running a command](https://github.com/fgrehm/vagrant-cachier/blob/master/lib/vagrant-cachier/cap/linux/rvm_path.rb#L10)
|
39
|
+
on the guest VM (like [rvm](buckets/rvm)) and you might even need to [tweak some configs](https://github.com/fgrehm/vagrant-cachier/blob/master/lib/vagrant-cachier/bucket/yum.rb#L20)
|
40
|
+
on the guest (like the [yum](buckets/yum) bucket).
|
41
|
+
|
42
|
+
There's currently a lot of duplication around the "installation" of cache buckets
|
43
|
+
so there's plenty of source code for you to read in order to understand how
|
44
|
+
things work under the hood but if you don't feel comfortable reading / writing
|
45
|
+
Ruby code you can provide a high level overview of how to do things using plain
|
46
|
+
old bash.
|
47
|
+
|
48
|
+
For example, if you were to explain how to set up the rvm bucket, the script
|
49
|
+
below should give vagrant-cachier maintainers an overview of how to set things
|
50
|
+
up:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
# Check is rvm is installed
|
54
|
+
if ! $(rvm info > /dev/null); then
|
55
|
+
exit 0
|
56
|
+
fi
|
57
|
+
|
58
|
+
# If it is installed, read the cache dir
|
59
|
+
RVM_CACHE="${rvm_path}/archives"
|
60
|
+
|
61
|
+
# "Install" the bucket!
|
62
|
+
mkdir -p /tmp/vagrant-cache/rvm/archives
|
63
|
+
ln -s /tmp/vagrant-cache/rvm/archives $RVM_CACHE
|
64
|
+
```
|
@@ -0,0 +1,32 @@
|
|
1
|
+
## How does it work?
|
2
|
+
|
3
|
+
On vagrant-cachier's _"jargon"_, cached packages are kept in _cache buckets_.
|
4
|
+
Those _buckets_ are basically directories that are shared between the host machine
|
5
|
+
and VMs that are kept around between `vagrant destroy`s. Each _bucket_ (or synced
|
6
|
+
folder if you prefer) is meant to cache specific types of packages, like [apt](buckets/apt)'s
|
7
|
+
`.deb`s or [RubyGems](buckets/rubygems) `.gem`s. Please have a look at the
|
8
|
+
"Available Buckets" menu above for more information on each bucket.
|
9
|
+
|
10
|
+
Regarding configurations, right now the plugin does not make any assumptions for
|
11
|
+
you and you have to configure things properly from your `Vagrantfile`. In other
|
12
|
+
words, _the plugin is disabled by default_.
|
13
|
+
|
14
|
+
Cache buckets will always be available from `/tmp/vagrant-cachier` on your guest and
|
15
|
+
the appropriate folders will get symlinked to the right path _after_ the machine is
|
16
|
+
up but _right before_ it gets provisioned. We _could_ potentially do it on one go
|
17
|
+
and share bucket's folders directly to the right path if we were only using VirtualBox
|
18
|
+
because it shares folders _after_ booting the machine but the LXC provider does that
|
19
|
+
_as part of_ the boot process (synced folders are actually `lxc-start` parameters)
|
20
|
+
and as of now we are not able to get some information that this plugin requires
|
21
|
+
about the guest machine / container before it is actually up and running.
|
22
|
+
|
23
|
+
Under the hood, the plugin will monkey patch `Vagrant::Builtin::Provision` and
|
24
|
+
will set things up for each configured cache bucket _before and after_ running each
|
25
|
+
defined provisioner. Before halting the machine, it will also revert the changes
|
26
|
+
required to set things up by hooking into calls to `Vagrant::Builtin::GracefulHalt`
|
27
|
+
so that you can repackage the machine for others to use without requiring users to
|
28
|
+
install the plugin as well.
|
29
|
+
|
30
|
+
Please keep in mind that this plugin won't do magic, if you are compiling things
|
31
|
+
during provisioning or manually downloading packages outside of a bucket you
|
32
|
+
won't see that much of improvement.
|
data/docs/index.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# vagrant-cachier
|
2
|
+
|
3
|
+
A [Vagrant](http://www.vagrantup.com/) plugin that helps you reduce the amount of
|
4
|
+
coffee you drink while waiting for boxes to be provisioned by sharing a common
|
5
|
+
package cache among similiar VM instances. Kinda like [vagrant-apt_cache](https://github.com/avit/vagrant-apt_cache)
|
6
|
+
or [this magical snippet](http://gist.github.com/juanje/3797297) but targetting
|
7
|
+
multiple package managers and Linux distros.
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Make sure you have Vagrant 1.2+ and run:
|
13
|
+
|
14
|
+
```
|
15
|
+
vagrant plugin install vagrant-cachier
|
16
|
+
```
|
17
|
+
|
18
|
+
## Quick start
|
19
|
+
|
20
|
+
The easiest way to set things up is just to enable [cache buckets auto detection](usage)
|
21
|
+
from within your `Vagrantfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Vagrant.configure("2") do |config|
|
25
|
+
config.vm.box = 'your-box'
|
26
|
+
config.cache.auto_detect = true
|
27
|
+
# If you are using VirtualBox, you might want to enable NFS for shared folders
|
28
|
+
# config.cache.enable_nfs = true
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
For more information please check out the links on the menu above.
|
33
|
+
|
34
|
+
|
35
|
+
## Compatible providers
|
36
|
+
|
37
|
+
* Vagrant's built in VirtualBox provider
|
38
|
+
* [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc)
|
39
|
+
* [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See
|
40
|
+
[GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info)
|
41
|
+
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/docs/template.html
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>{{NAME}} :: viewdocs.io</title>
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<meta charset="utf-8">
|
7
|
+
|
8
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/3.0.2/yeti/bootstrap.min.css">
|
9
|
+
<link rel="stylesheet" href="http://fgrehm.github.io/viewdocs-yeti/stylesheets/pygment_trac.css">
|
10
|
+
|
11
|
+
<style>
|
12
|
+
html, body {
|
13
|
+
height: 100%;
|
14
|
+
margin: 0;
|
15
|
+
padding: 0;
|
16
|
+
/* The html and body elements cannot have any padding or margin. */
|
17
|
+
}
|
18
|
+
|
19
|
+
/* Wrapper for page content to push down footer */
|
20
|
+
#wrap {
|
21
|
+
min-height: 100%;
|
22
|
+
height: auto;
|
23
|
+
/* Negative indent footer by its height */
|
24
|
+
margin: 0 auto -60px;
|
25
|
+
/* Pad bottom by footer height */
|
26
|
+
padding: 0 0 60px;
|
27
|
+
}
|
28
|
+
|
29
|
+
/* Set the fixed height of the footer here */
|
30
|
+
footer {
|
31
|
+
height: 60px;
|
32
|
+
background-color: #f5f5f5;
|
33
|
+
padding-top: 9px;
|
34
|
+
}
|
35
|
+
|
36
|
+
footer p {
|
37
|
+
clear: left;
|
38
|
+
margin-bottom: 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
#wrap > .container {
|
42
|
+
padding-top: 60px;
|
43
|
+
}
|
44
|
+
.navbar-nav>li>iframe {
|
45
|
+
margin-top: 12px;
|
46
|
+
}
|
47
|
+
|
48
|
+
th {
|
49
|
+
padding: 10px;
|
50
|
+
}
|
51
|
+
</style>
|
52
|
+
|
53
|
+
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
54
|
+
<!--[if lt IE 9]>
|
55
|
+
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
56
|
+
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
57
|
+
<![endif]-->
|
58
|
+
</head>
|
59
|
+
<body>
|
60
|
+
<div id="wrap">
|
61
|
+
<div class="navbar navbar-default navbar-fixed-top">
|
62
|
+
<div class="container">
|
63
|
+
<div class="navbar-header">
|
64
|
+
<a href="/{{NAME}}" class="navbar-brand">{{NAME}}</a>
|
65
|
+
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
|
66
|
+
<span class="icon-bar"></span>
|
67
|
+
<span class="icon-bar"></span>
|
68
|
+
<span class="icon-bar"></span>
|
69
|
+
</button>
|
70
|
+
</div>
|
71
|
+
<div class="navbar-collapse collapse" id="navbar-main">
|
72
|
+
<ul class="nav navbar-nav">
|
73
|
+
<li>
|
74
|
+
<a href="usage">Usage</a>
|
75
|
+
</li>
|
76
|
+
<li>
|
77
|
+
<a href="how-does-it-work">How does it work?</a>
|
78
|
+
</li>
|
79
|
+
<li>
|
80
|
+
<a href="benchmarks">Benchmarks</a>
|
81
|
+
</li>
|
82
|
+
<li class="dropdown">
|
83
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Available Buckets <span class="caret"></span></a>
|
84
|
+
<ul class="dropdown-menu">
|
85
|
+
<li><a tabindex="-1" href="buckets/apt">APT</a></li>
|
86
|
+
<li><a tabindex="-1" href="buckets/apt-cacher">apt-cacher</a></li>
|
87
|
+
<li><a tabindex="-1" href="buckets/chef">Chef</a></li>
|
88
|
+
<li><a tabindex="-1" href="buckets/composer">Composer</a></li>
|
89
|
+
<li><a tabindex="-1" href="buckets/pacman">Pacman</a></li>
|
90
|
+
<li><a tabindex="-1" href="buckets/npm">npm</a></li>
|
91
|
+
<li><a tabindex="-1" href="buckets/rubygems">RubyGems</a></li>
|
92
|
+
<li><a tabindex="-1" href="buckets/rvm">rvm</a></li>
|
93
|
+
<li><a tabindex="-1" href="buckets/yum">Yum</a></li>
|
94
|
+
<li><a tabindex="-1" href="buckets/zypper">Zypper</a></li>
|
95
|
+
</ul>
|
96
|
+
</li>
|
97
|
+
<li>
|
98
|
+
<a href="development">Development</a>
|
99
|
+
</li>
|
100
|
+
</ul>
|
101
|
+
|
102
|
+
<ul class="nav navbar-nav navbar-right visible-md visible-lg">
|
103
|
+
<li><iframe src="http://ghbtns.com/github-btn.html?user={{USER}}&repo={{NAME}}&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe></li>
|
104
|
+
<li><iframe src="http://ghbtns.com/github-btn.html?user={{USER}}&repo={{NAME}}&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe></li>
|
105
|
+
</ul>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div class="container">
|
111
|
+
{{CONTENT}}
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<footer>
|
116
|
+
<div class="container">
|
117
|
+
<div class="row">
|
118
|
+
<div class="col-lg-12">
|
119
|
+
<p>Hosted on <a href="http://viewdocs.io">http://viewdocs.io</a>.</p>
|
120
|
+
<p>Theme based on <a href="http://bootswatch.com/yeti/">Yeti</a> built by <a href="http://thomaspark.me">Thomas Park</a> and adapted to Viewdocs by <a href="http://fabiorehm.com/">Fábio Rehm</a>.</p>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
</footer>
|
125
|
+
|
126
|
+
<script src="//oss.maxcdn.com/libs/jquery/2.0.3/jquery.min.js"></script>
|
127
|
+
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
|
128
|
+
<script>
|
129
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
130
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
131
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
132
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
133
|
+
ga('create', 'UA-38687494-5', 'viewdocs.io');
|
134
|
+
ga('send', 'pageview');
|
135
|
+
</script>
|
136
|
+
</body>
|
137
|
+
</html>
|
data/docs/usage.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Usage
|
2
|
+
|
3
|
+
## Auto detect supported cache buckets
|
4
|
+
|
5
|
+
This is the easiest way to get started with plugin. By adding the code below to
|
6
|
+
your `Vagrantfile` you can enable automatic detection of supported cache _buckets_:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
Vagrant.configure("2") do |config|
|
10
|
+
# ...
|
11
|
+
config.cache.auto_detect = true
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
This will make vagrant-cachier do its best to find out what is supported on the
|
16
|
+
guest machine and will set buckets accordingly.
|
17
|
+
|
18
|
+
## Enable buckets as needed
|
19
|
+
|
20
|
+
If for whatever reason you need to have a fined grained control over what buckets
|
21
|
+
are configured, you can do so by "cherry picking" them on your `Vagrantfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Vagrant.configure("2") do |config|
|
25
|
+
config.cache.enable :apt
|
26
|
+
config.cache.enable :gem
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
_Please refer to the "Available Buckets" menu above to find out which buckets
|
31
|
+
are supported._
|
32
|
+
|
33
|
+
## Cache scope
|
34
|
+
|
35
|
+
By default downloaded packages will get stored on a folder scoped to base boxes
|
36
|
+
under your `$HOME/.vagrant.d/cache`. The idea is to leverage the cache by allowing
|
37
|
+
downloaded packages to be reused across projects. So, if your `Vagrantfile` has
|
38
|
+
something like:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Vagrant.configure("2") do |config|
|
42
|
+
config.vm.box = 'some-box'
|
43
|
+
config.cache.auto_detect = true
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
The cached files will be stored under `$HOME/.vagrant.d/cache/some-box`.
|
48
|
+
|
49
|
+
If you are on a [multi VM environment](http://docs.vagrantup.com/v2/multi-machine/index.html),
|
50
|
+
there is a huge chance that you'll end up having issues by sharing the same bucket
|
51
|
+
across different machines. For example, if you `apt-get install` from two machines
|
52
|
+
at "almost the same time" you are probably going to hit a _"SystemError: Failed to
|
53
|
+
lock /var/cache/apt/archives/lock"_. To work around that, you can set the scope
|
54
|
+
to be based on machines:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Vagrant.configure("2") do |config|
|
58
|
+
config.vm.box = 'some-box'
|
59
|
+
config.cache.scope = :machine
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
This will tell vagrant-cachier to download packages to `.vagrant/machines/<machine-name>/cache`
|
64
|
+
on your current project directory.
|
65
|
+
|
66
|
+
|
67
|
+
## Finding out disk space used by buckets
|
68
|
+
|
69
|
+
At some point we might implement a `vagrant cache stats` command that will give you that
|
70
|
+
information, but while that does not get implemented you can run the code below
|
71
|
+
if you are on a Linux machine:
|
72
|
+
|
73
|
+
```
|
74
|
+
# scope = :box (default)
|
75
|
+
$ du -h -d0 $HOME/.vagrant.d/cache
|
76
|
+
405M /home/user/.vagrant.d/cache/precise64
|
77
|
+
1.1G /home/user/.vagrant.d/cache/raring64
|
78
|
+
448M /home/user/.vagrant.d/cache/quantal64
|
79
|
+
|
80
|
+
# scope = :machine
|
81
|
+
$ du -h -d0 .vagrant/machines/*/cache
|
82
|
+
16K .vagrant/machines/precise/cache
|
83
|
+
90M .vagrant/machines/quantal/cache
|
84
|
+
210M .vagrant/machines/raring/cache
|
85
|
+
```
|
86
|
+
|
87
|
+
## Cleaning up cache buckets
|
88
|
+
|
89
|
+
At some point we might implement a `vagrant cache clean [bucket-name]` command that will
|
90
|
+
take care of things for you, but while that does not get implemented you can run
|
91
|
+
the code below if you are on a Linux machine:
|
92
|
+
|
93
|
+
```
|
94
|
+
# scope = :box (default)
|
95
|
+
$ rm -rf $HOME/.vagrant.d/cache/<box-name>/<optional-bucket-name>
|
96
|
+
|
97
|
+
# scope = :machine
|
98
|
+
$ rm -rf .vagrant/cache/<box-name>/<optional-bucket-name>
|
99
|
+
```
|
@@ -17,8 +17,12 @@ module VagrantPlugins
|
|
17
17
|
|
18
18
|
FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?
|
19
19
|
|
20
|
-
|
21
|
-
env[:machine].config.
|
20
|
+
synced_folder_opts = {id: "vagrant-cache"}
|
21
|
+
if env[:machine].config.cache.enable_nfs
|
22
|
+
# REFACTOR: Drop the `nfs: true` argument once we drop support for Vagrant < 1.4
|
23
|
+
synced_folder_opts.merge!({ nfs: true, type: 'nfs' })
|
24
|
+
end
|
25
|
+
env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', synced_folder_opts
|
22
26
|
|
23
27
|
env[:cache_dirs] = []
|
24
28
|
|
@@ -4,6 +4,7 @@ Vagrant.configure("2") do |config|
|
|
4
4
|
config.cache.auto_detect = true
|
5
5
|
config.cache.scope = :machine
|
6
6
|
|
7
|
-
config.vm.box = '
|
7
|
+
config.vm.box = 'precise64'
|
8
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
8
9
|
config.vm.provision :shell, inline: 'apt-get update && apt-get install -y git'
|
9
10
|
end
|
@@ -2,6 +2,7 @@ Vagrant.require_plugin 'vagrant-cachier'
|
|
2
2
|
Vagrant.require_plugin 'vagrant-lxc'
|
3
3
|
Vagrant.configure("2") do |config|
|
4
4
|
config.cache.auto_detect = true
|
5
|
-
config.vm.box = '
|
5
|
+
config.vm.box = 'precise64'
|
6
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
6
7
|
config.vm.provision :shell, inline: 'echo Hello!'
|
7
8
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
Vagrant.require_plugin 'vagrant-cachier'
|
2
2
|
Vagrant.require_plugin 'vagrant-lxc'
|
3
3
|
Vagrant.configure("2") do |config|
|
4
|
-
config.vm.box = '
|
4
|
+
config.vm.box = 'precise64'
|
5
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
5
6
|
config.vm.provision :shell, inline: 'echo Hello!'
|
6
7
|
end
|
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.5.
|
4
|
+
version: 0.5.1
|
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-
|
11
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Speed up vagrant boxes provisioning
|
14
14
|
email:
|
@@ -27,6 +27,22 @@ files:
|
|
27
27
|
- development/Cheffile
|
28
28
|
- development/Cheffile.lock
|
29
29
|
- development/Vagrantfile
|
30
|
+
- docs/benchmarks.md
|
31
|
+
- docs/buckets/apt-cacher.md
|
32
|
+
- docs/buckets/apt.md
|
33
|
+
- docs/buckets/chef.md
|
34
|
+
- docs/buckets/composer.md
|
35
|
+
- docs/buckets/npm.md
|
36
|
+
- docs/buckets/pacman.md
|
37
|
+
- docs/buckets/rubygems.md
|
38
|
+
- docs/buckets/rvm.md
|
39
|
+
- docs/buckets/yum.md
|
40
|
+
- docs/buckets/zypper.md
|
41
|
+
- docs/development.md
|
42
|
+
- docs/how-does-it-work.md
|
43
|
+
- docs/index.md
|
44
|
+
- docs/template.html
|
45
|
+
- docs/usage.md
|
30
46
|
- lib/vagrant-cachier.rb
|
31
47
|
- lib/vagrant-cachier/action/clean.rb
|
32
48
|
- lib/vagrant-cachier/action/ensure_single_cache_root.rb
|