Compare commits
240 commits
Author | SHA1 | Date | |
---|---|---|---|
0cc4a27f32 | |||
|
7e885eb8a4 | ||
|
39bd2a8704 | ||
|
e4cc2f91a4 | ||
|
ceb4d98a22 | ||
|
a0cdcb05a2 | ||
|
fad6bbf6a0 | ||
|
5141e1305a | ||
|
959ac6fbcc | ||
|
da0eff6a71 | ||
|
c42420ec7c | ||
|
8615b7495e | ||
|
6deb452f0d | ||
|
1c3fcd2768 | ||
|
40dddfb368 | ||
|
dd32f2472e | ||
|
3b18f4a5ec | ||
|
2c2411721b | ||
|
92b95824ba | ||
|
2bb7f21273 | ||
|
00e2d858da | ||
|
e227077008 | ||
|
050e9ea464 | ||
|
f09af37533 | ||
|
c6d4e57554 | ||
|
15b0039467 | ||
|
4647721f85 | ||
|
9f6b615e84 | ||
|
1ccdbbeb48 | ||
|
21f475212c | ||
|
837003ed48 | ||
|
babc7e09ff | ||
|
1fe3e15c64 | ||
|
973d5d1a8f | ||
|
e9f4df338a | ||
|
b2b0d98dfa | ||
|
1333041059 | ||
|
7acbc815cf | ||
|
137bb91eec | ||
|
25f5582e20 | ||
|
25b5fa0285 | ||
|
4ab1640e7e | ||
|
b7b3bcb3ed | ||
|
c7c47782cb | ||
|
d94f08a048 | ||
|
1a1b108c23 | ||
|
2b6a07d000 | ||
|
f8314aba52 | ||
|
871f317ba6 | ||
|
44aa6a6c54 | ||
|
c4db3c1ef4 | ||
|
4265f58985 | ||
|
2b00036484 | ||
|
82fe74a888 | ||
|
5f4a7f1967 | ||
|
183b2b55d8 | ||
|
2cc7b837db | ||
|
2b8a281e8a | ||
|
d885c901b9 | ||
|
6bca147fb9 | ||
|
228cae4a9a | ||
|
e6826e6864 | ||
|
2c51c7e636 | ||
|
5dbd5511fa | ||
|
bbd1e9c901 | ||
|
5598824558 | ||
|
6f275353b8 | ||
|
6e160ba4cb | ||
|
f545717587 | ||
|
f65a1217e9 | ||
|
3997e2abc7 | ||
|
364876d8e9 | ||
|
8ac8d7f6f6 | ||
|
184330dfb4 | ||
|
ff5dd72c73 | ||
|
7aea5a0ab0 | ||
|
f10a2d488e | ||
|
12f121e6e4 | ||
|
20373aa0d7 | ||
|
0f3d79e1bc | ||
|
5d9c433326 | ||
|
155821448f | ||
|
890f7c4a56 | ||
|
04102aac8e | ||
|
a4c5f05263 | ||
|
8d48dacf24 | ||
|
2a17bc4f1d | ||
|
ffd6c514dd | ||
|
b28da3ab26 | ||
|
ff2bc00ee3 | ||
|
a63156e482 | ||
|
2df1e31940 | ||
|
2faa661546 | ||
|
ede55cdfaf | ||
|
33dee6419a | ||
|
ec96099e25 | ||
|
4bb48baf40 | ||
|
f968e2d458 | ||
|
2db38dfa6e | ||
|
b8394f7e6a | ||
|
ac4243d85e | ||
|
09966efc26 | ||
|
5d617f2c48 | ||
|
ae85e996ed | ||
|
2a63617e75 | ||
|
01bef9f407 | ||
|
07df936e4a | ||
|
b4d12be2e5 | ||
|
437ba6a4cf | ||
|
1c2116f317 | ||
|
1fa46ca2d4 | ||
|
8d6c7c62da | ||
|
0dd1b20053 | ||
|
59887560ed | ||
|
849374e0d1 | ||
|
aaff51fda8 | ||
|
509872e91b | ||
|
29a4c3c45e | ||
|
2296d35251 | ||
|
7d7f048dfb | ||
|
6bf733d8ed | ||
|
6df1efd0ba | ||
|
a8f05e4b11 | ||
|
ea88562145 | ||
|
0106155a0f | ||
|
09d65c4a3c | ||
|
8a4b911678 | ||
|
b65438007d | ||
|
ca8764f938 | ||
|
6908b94609 | ||
|
2f75ffe692 | ||
|
0f533a9b30 | ||
|
aa793367b7 | ||
|
e01a78138a | ||
|
daf7488bbc | ||
|
d823a97cb8 | ||
|
4ffb47f838 | ||
|
e4f6dd69e4 | ||
|
fccd43d8e2 | ||
|
8ae667ead9 | ||
|
cdf13d3f70 | ||
|
3b83867427 | ||
|
9c7b02b3ac | ||
|
ed6c76dedf | ||
|
1541f35ef8 | ||
|
98c211590c | ||
|
5ff8d1013a | ||
|
1bc96e77d3 | ||
|
4668f1d486 | ||
|
12f7963d1f | ||
|
949df52a26 | ||
|
5342a7ce33 | ||
|
50f4536ff7 | ||
|
27b87567a5 | ||
|
4e3d352848 | ||
|
02ac1769d2 | ||
|
3de0118d50 | ||
|
aa46abac37 | ||
|
ba841b1c53 | ||
|
e2da4dd537 | ||
|
354c9ca2b5 | ||
|
d8e195bb63 | ||
|
f1618d7d14 | ||
|
b28ac072a5 | ||
|
3421b4489a | ||
|
27788c995c | ||
|
5a488a2972 | ||
|
54407fd2da | ||
|
c4ba0c9445 | ||
|
fb97820993 | ||
|
16b68e72f1 | ||
|
3c4a20f44d | ||
|
0340d6e76b | ||
|
03b2b80121 | ||
|
00f4aaa28c | ||
|
94ba773ce6 | ||
|
2734186347 | ||
|
94de55a241 | ||
|
eb544ae773 | ||
|
fc6819ce00 | ||
|
1862eeca61 | ||
|
5e5070dc14 | ||
|
e960cdb265 | ||
|
56b86a0deb | ||
|
2cb0610cc1 | ||
|
a9f41c5f01 | ||
|
fc9a07dfba | ||
|
4d01bff390 | ||
|
00c9cce50d | ||
|
6a8d661e97 | ||
|
0704ca2ce2 | ||
|
9e0e0d50b5 | ||
|
93c0c7bf99 | ||
|
536ca7ad54 | ||
|
c85558010a | ||
|
17a475a688 | ||
|
7bc70b7d6e | ||
|
8e40d0c060 | ||
|
d558a0ac7f | ||
|
64c9b91cf9 | ||
|
2b56bef572 | ||
|
b769618f81 | ||
|
850841fe0a | ||
|
e0eeb125d0 | ||
|
f38db9efc4 | ||
|
b1aa9a1967 | ||
|
42cd490313 | ||
|
06d80b47f9 | ||
|
ee6174d33c | ||
|
f8e419b8b6 | ||
|
a0a164cf2b | ||
|
828793afde | ||
|
817d964b8e | ||
|
fa8c59a16c | ||
|
cfabddc7c8 | ||
|
199a14b61f | ||
|
9ebdc24da4 | ||
|
cfa2cc262f | ||
|
24c1d3a8ac | ||
|
88a06626a2 | ||
|
4e0d1bd8cd | ||
|
4972ec0fa5 | ||
|
d6066fbde7 | ||
|
11defb0b29 | ||
|
b0180b16d9 | ||
|
f8484f7343 | ||
|
0b13040888 | ||
|
246ab52380 | ||
|
8e89c0b1d5 | ||
|
837399cd0f | ||
|
2e7d6d4f32 | ||
|
079f1fccbb | ||
|
49b36c012a | ||
|
8efb8daf07 | ||
|
92b36edee9 | ||
|
8b0b08eace | ||
|
fdd6daa5fc | ||
|
b0110897a7 | ||
|
ce6e08fd0d | ||
|
064160288a |
80 changed files with 2224 additions and 657 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,4 +15,3 @@ test/tmp
|
||||||
test/version_tmp
|
test/version_tmp
|
||||||
tmp
|
tmp
|
||||||
.vagrant
|
.vagrant
|
||||||
development/cookbooks
|
|
||||||
|
|
185
CHANGELOG.md
185
CHANGELOG.md
|
@ -1,3 +1,188 @@
|
||||||
|
## [1.2.1](https://github.com/fgrehm/vagrant-cachier/compare/v1.2.0...v1.2.1) (July 3, 2015)
|
||||||
|
|
||||||
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
- Add chef\_zero support to chef bucket [[GH-153]]
|
||||||
|
|
||||||
|
[GH-153]: https://github.com/fgrehm/vagrant-cachier/issues/153
|
||||||
|
|
||||||
|
## [1.2.0](https://github.com/fgrehm/vagrant-cachier/compare/v1.1.0...v1.2.0) (Jan 14, 2015)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- [Chef Gems bucket](http://fgrehm.viewdocs.io/vagrant-cachier/buckets/chef_rubygems) [[GH-129]]
|
||||||
|
|
||||||
|
[GH-129]: https://github.com/fgrehm/vagrant-cachier/pull/129
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Fix provisioner resolution on Vagrant 1.7+ [[GH-133]] / [[GH-134]]
|
||||||
|
- Do not modify Vagrant core object, preventing unpredictable behavior [[GH-135]]
|
||||||
|
|
||||||
|
[GH-133]: https://github.com/fgrehm/vagrant-cachier/issues/133
|
||||||
|
[GH-134]: https://github.com/fgrehm/vagrant-cachier/pull/134
|
||||||
|
[GH-135]: https://github.com/fgrehm/vagrant-cachier/pull/135
|
||||||
|
|
||||||
|
|
||||||
|
## [1.1.0](https://github.com/fgrehm/vagrant-cachier/compare/v1.0.0...v1.1.0) (Oct 15, 2014)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- [Bower bucket](http://fgrehm.viewdocs.io/vagrant-cachier/buckets/bower) [[GH-125]]
|
||||||
|
|
||||||
|
[GH-125]: https://github.com/fgrehm/vagrant-cachier/pull/125
|
||||||
|
|
||||||
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
- Resolve $HOME even if VM spits bogus new lines [[GH-122]] / [[GH-124]]
|
||||||
|
|
||||||
|
[GH-122]: https://github.com/fgrehm/vagrant-cachier/issues/122
|
||||||
|
[GH-124]: https://github.com/fgrehm/vagrant-cachier/pull/124
|
||||||
|
|
||||||
|
## [1.0.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.9.0...v1.0.0) (Sep 22, 2014)
|
||||||
|
|
||||||
|
Public API is considered stable.
|
||||||
|
|
||||||
|
|
||||||
|
## [0.9.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.8.0...v0.9.0) (Aug 9, 2014)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- Suport for caching packages for Docker containers that doesn't have a base box specified [[GH-116]]
|
||||||
|
|
||||||
|
[GH-116]: https://github.com/fgrehm/vagrant-cachier/pull/116
|
||||||
|
|
||||||
|
## [0.8.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.7.2...v0.8.0) (Jul 20, 2014)
|
||||||
|
|
||||||
|
BACKWARDS INCOMPATIBILITIES:
|
||||||
|
|
||||||
|
- Removed deprecated `config.enable_nfs` config.
|
||||||
|
- Changed composer cache bucket to use `$HOME/.composer/cache` [[GH-89]]
|
||||||
|
|
||||||
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
- Set composer cache bucket ownership to the configured SSH user.
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Automatically disable apt-lists bucket when a Windows host is detected [[GH-106]]
|
||||||
|
- Skip `chmod 777` for `smb` mounted folders [[GH-107]]
|
||||||
|
- Do not error if base box has been removed and `:box` is configured as the cache scope [[GH-86]]
|
||||||
|
|
||||||
|
[GH-86]: https://github.com/fgrehm/vagrant-cachier/issues/86
|
||||||
|
[GH-89]: https://github.com/fgrehm/vagrant-cachier/issues/89
|
||||||
|
[GH-106]: https://github.com/fgrehm/vagrant-cachier/issues/106
|
||||||
|
[GH-107]: https://github.com/fgrehm/vagrant-cachier/issues/107
|
||||||
|
|
||||||
|
## [0.7.2](https://github.com/fgrehm/vagrant-cachier/compare/v0.7.1...v0.7.2) (May 08, 2014)
|
||||||
|
|
||||||
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
- Add `azure`, `brightbox`, `cloudstack`, `vcloud` and `vsphere` to the list
|
||||||
|
of known cloud providers [[GH-104]]
|
||||||
|
|
||||||
|
[GH-104]: https://github.com/fgrehm/vagrant-cachier/pull/104
|
||||||
|
|
||||||
|
## [0.7.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.7.0...v0.7.1) (May 04, 2014)
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Fix support for using multiple generic buckets [[GH-101]]
|
||||||
|
|
||||||
|
[GH-101]: https://github.com/fgrehm/vagrant-cachier/pull/101
|
||||||
|
|
||||||
|
|
||||||
|
## [0.7.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.6.0...v0.7.0) (Apr 06, 2014)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- ["Generic" cache bucket](http://fgrehm.viewdocs.io/vagrant-cachier/buckets/generic) [[GH-94]] / [[GH-4]].
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Fix apt-cacher bucket undefined method error [[GH-96]]
|
||||||
|
|
||||||
|
[GH-94]: https://github.com/fgrehm/vagrant-cachier/pull/94
|
||||||
|
[GH-4]: https://github.com/fgrehm/vagrant-cachier/issues/4
|
||||||
|
[GH-96]: https://github.com/fgrehm/vagrant-cachier/issues/96
|
||||||
|
|
||||||
|
## [0.6.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.1...v0.6.0) (Feb 26, 2014)
|
||||||
|
|
||||||
|
BACKWARDS INCOMPATIBILITIES:
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Fix NFS support for Vagrant 1.4+ [GH-67]
|
||||||
|
|
||||||
|
## [0.5.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.1...v0.5.0) (Nov 8, 2013)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- Support for [zypper] [GH-54]
|
||||||
|
|
||||||
|
## [0.4.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.0...v0.4.1) (Oct 27, 2013)
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Do not attempt to configure apt-cacher-ng bucket if it is not installed on guest
|
||||||
|
machine.
|
||||||
|
|
||||||
|
## [0.4.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.3...v0.4.0) (Oct 23, 2013)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
|
||||||
|
- Support for [npm](https://npmjs.org/) [GH-51]
|
||||||
|
- Support for [Composer](http://getcomposer.org/) [GH-48]
|
||||||
|
- Support for `apt-cacher-ng` [GH-30]
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Allow halting nonresponsive machine when plugin is installed [GH-8]
|
||||||
|
|
||||||
|
## [0.3.3](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.2...v0.3.3) (Sep 11, 2013)
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Automatically create `partial` dir under apt cache bucket dir to allow usage
|
||||||
|
on Ubuntu 10.04 guests [GH-40]
|
||||||
|
|
||||||
|
## [0.3.2](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.1...v0.3.2) (Aug 14, 2013)
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
- Prevent errors when caching is disabled and a provisioner is enabled [GH-41]
|
||||||
|
|
||||||
## [0.3.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.0...v0.3.1) (Aug 13, 2013)
|
## [0.3.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.3.0...v0.3.1) (Aug 13, 2013)
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
16
Gemfile
16
Gemfile
|
@ -1,13 +1,13 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
# Specify your gem's dependencies in vagrant-cachier.gemspec
|
|
||||||
gemspec
|
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'vagrant', github: 'mitchellh/vagrant'
|
gem 'vagrant', github: 'mitchellh/vagrant', tag: 'v1.7.2'
|
||||||
gem 'vagrant-lxc', github: 'fgrehm/vagrant-lxc'
|
|
||||||
gem 'vagrant-pristine', github: 'fgrehm/vagrant-pristine'
|
|
||||||
gem 'vagrant-librarian-chef'
|
|
||||||
gem 'vagrant-omnibus'
|
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :plugins do
|
||||||
|
gemspec
|
||||||
|
gem 'vagrant-lxc', github: 'fgrehm/vagrant-lxc'
|
||||||
|
gem 'vagrant-pristine', github: 'fgrehm/vagrant-pristine'
|
||||||
|
gem 'vagrant-omnibus'
|
||||||
|
end
|
||||||
|
|
159
Gemfile.lock
159
Gemfile.lock
|
@ -1,98 +1,119 @@
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/fgrehm/vagrant-lxc.git
|
remote: git://github.com/fgrehm/vagrant-lxc.git
|
||||||
revision: 5ae82681cdedaf2a6f778e005dd65014fc7c2cec
|
revision: c9cd671a32f730fff4b6e4fdd3687a531af0663c
|
||||||
specs:
|
specs:
|
||||||
vagrant-lxc (0.5.1.dev)
|
vagrant-lxc (1.1.0)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/fgrehm/vagrant-pristine.git
|
remote: git://github.com/fgrehm/vagrant-pristine.git
|
||||||
revision: 5c400d7850fc5f98d9601b59f4c3bd74818650de
|
revision: 503dbc47848c81d0fbfa6840491856f518d244a1
|
||||||
specs:
|
specs:
|
||||||
vagrant-pristine (0.2.0)
|
vagrant-pristine (0.3.0)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/mitchellh/vagrant.git
|
remote: git://github.com/mitchellh/vagrant.git
|
||||||
revision: 16002d03c07f842a23497543129fa99f40f2bbc0
|
revision: 1cd667b243f4a263cd5322b6455165cc676b6f7f
|
||||||
|
tag: v1.7.2
|
||||||
specs:
|
specs:
|
||||||
vagrant (1.2.8.dev)
|
vagrant (1.7.2)
|
||||||
childprocess (~> 0.3.7)
|
bundler (>= 1.5.2, < 1.8.0)
|
||||||
|
childprocess (~> 0.5.0)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
|
hashicorp-checkpoint (~> 0.1.1)
|
||||||
i18n (~> 0.6.0)
|
i18n (~> 0.6.0)
|
||||||
log4r (~> 1.1.9)
|
listen (~> 2.8.0)
|
||||||
|
log4r (~> 1.1.9, < 1.1.11)
|
||||||
net-scp (~> 1.1.0)
|
net-scp (~> 1.1.0)
|
||||||
net-ssh (~> 2.6.6)
|
net-sftp (~> 2.1)
|
||||||
|
net-ssh (>= 2.6.6, < 2.10.0)
|
||||||
|
nokogiri (= 1.6.3.1)
|
||||||
|
rb-kqueue (~> 0.2.0)
|
||||||
|
rest-client (>= 1.6.0, < 2.0)
|
||||||
|
wdm (~> 0.1.0)
|
||||||
|
winrm (~> 1.1.3)
|
||||||
|
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
vagrant-cachier (0.3.1)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
archive-tar-minitar (0.5.2)
|
akami (1.2.2)
|
||||||
chef (11.6.0)
|
gyoku (>= 0.4.0)
|
||||||
erubis
|
nokogiri
|
||||||
highline (>= 1.6.9)
|
builder (3.2.2)
|
||||||
json (>= 1.4.4, <= 1.7.7)
|
celluloid (0.16.0)
|
||||||
mixlib-authentication (>= 1.3.0)
|
timers (~> 4.0.0)
|
||||||
mixlib-cli (~> 1.3.0)
|
childprocess (0.5.5)
|
||||||
mixlib-config (>= 1.1.2)
|
|
||||||
mixlib-log (>= 1.3.0)
|
|
||||||
mixlib-shellout
|
|
||||||
net-ssh (~> 2.6)
|
|
||||||
net-ssh-multi (~> 1.1.0)
|
|
||||||
ohai (>= 0.6.0)
|
|
||||||
rest-client (>= 1.0.4, < 1.7.0)
|
|
||||||
yajl-ruby (~> 1.1)
|
|
||||||
childprocess (0.3.9)
|
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
ffi (1.9.0)
|
ffi (1.9.6)
|
||||||
highline (1.6.19)
|
gssapi (1.0.3)
|
||||||
i18n (0.6.4)
|
ffi (>= 1.0.1)
|
||||||
ipaddress (0.8.0)
|
gyoku (1.2.2)
|
||||||
json (1.7.7)
|
builder (>= 2.1.2)
|
||||||
librarian (0.1.0)
|
hashicorp-checkpoint (0.1.4)
|
||||||
highline
|
hitimes (1.2.2)
|
||||||
thor (~> 0.15)
|
httpclient (2.6.0.1)
|
||||||
librarian-chef (0.0.1)
|
httpi (0.9.7)
|
||||||
archive-tar-minitar (>= 0.5.2)
|
rack
|
||||||
chef (>= 0.10)
|
i18n (0.6.11)
|
||||||
librarian (~> 0.1.0)
|
listen (2.8.5)
|
||||||
|
celluloid (>= 0.15.2)
|
||||||
|
rb-fsevent (>= 0.9.3)
|
||||||
|
rb-inotify (>= 0.9)
|
||||||
|
little-plugger (1.1.3)
|
||||||
log4r (1.1.10)
|
log4r (1.1.10)
|
||||||
mime-types (1.23)
|
logging (1.8.2)
|
||||||
mixlib-authentication (1.3.0)
|
little-plugger (>= 1.1.3)
|
||||||
mixlib-log
|
multi_json (>= 1.8.4)
|
||||||
mixlib-cli (1.3.0)
|
mime-types (2.4.3)
|
||||||
mixlib-config (1.1.2)
|
mini_portile (0.6.0)
|
||||||
mixlib-log (1.6.0)
|
multi_json (1.10.1)
|
||||||
mixlib-shellout (1.2.0)
|
|
||||||
net-scp (1.1.2)
|
net-scp (1.1.2)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (2.6.8)
|
net-sftp (2.1.2)
|
||||||
net-ssh-gateway (1.2.0)
|
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh-multi (1.1)
|
net-ssh (2.9.2)
|
||||||
net-ssh (>= 2.1.4)
|
netrc (0.10.2)
|
||||||
net-ssh-gateway (>= 0.99.0)
|
nokogiri (1.6.3.1)
|
||||||
ohai (6.18.0)
|
mini_portile (= 0.6.0)
|
||||||
ipaddress
|
nori (1.1.5)
|
||||||
mixlib-cli
|
rack (1.6.0)
|
||||||
mixlib-config
|
rake (10.4.2)
|
||||||
mixlib-log
|
rb-fsevent (0.9.4)
|
||||||
mixlib-shellout
|
rb-inotify (0.9.5)
|
||||||
systemu
|
ffi (>= 0.5.0)
|
||||||
yajl-ruby
|
rb-kqueue (0.2.3)
|
||||||
rake (10.1.0)
|
ffi (>= 0.5.0)
|
||||||
rest-client (1.6.7)
|
rest-client (1.7.2)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16, < 3.0)
|
||||||
systemu (2.5.2)
|
netrc (~> 0.7)
|
||||||
thor (0.18.1)
|
rubyntlm (0.1.1)
|
||||||
vagrant-librarian-chef (0.1.2)
|
savon (0.9.5)
|
||||||
librarian-chef
|
akami (~> 1.0)
|
||||||
vagrant-omnibus (1.1.0)
|
builder (>= 2.1.2)
|
||||||
yajl-ruby (1.1.0)
|
gyoku (>= 0.4.0)
|
||||||
|
httpi (~> 0.9)
|
||||||
|
nokogiri (>= 1.4.0)
|
||||||
|
nori (~> 1.0)
|
||||||
|
wasabi (~> 1.0)
|
||||||
|
timers (4.0.1)
|
||||||
|
hitimes
|
||||||
|
uuidtools (2.1.5)
|
||||||
|
vagrant-omnibus (1.4.1)
|
||||||
|
wasabi (1.0.0)
|
||||||
|
nokogiri (>= 1.4.0)
|
||||||
|
wdm (0.1.0)
|
||||||
|
winrm (1.1.3)
|
||||||
|
gssapi (~> 1.0.0)
|
||||||
|
httpclient (~> 2.2, >= 2.2.0.2)
|
||||||
|
logging (~> 1.6, >= 1.6.1)
|
||||||
|
nokogiri (~> 1.5)
|
||||||
|
rubyntlm (~> 0.1.1)
|
||||||
|
savon (= 0.9.5)
|
||||||
|
uuidtools (~> 2.1.2)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -101,7 +122,9 @@ DEPENDENCIES
|
||||||
rake
|
rake
|
||||||
vagrant!
|
vagrant!
|
||||||
vagrant-cachier!
|
vagrant-cachier!
|
||||||
vagrant-librarian-chef
|
|
||||||
vagrant-lxc!
|
vagrant-lxc!
|
||||||
vagrant-omnibus
|
vagrant-omnibus
|
||||||
vagrant-pristine!
|
vagrant-pristine!
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.4
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2013 Fabio Rehm
|
Copyright (c) 2013-2014 Fabio Rehm
|
||||||
|
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
|
|
239
README.md
239
README.md
|
@ -1,229 +1,70 @@
|
||||||
|
🟢 We plan to support and maintain vagrant-lxc, as well as clean it up.<br/>
|
||||||
|
🟢 Please feel free to contribute Issues and pull requests.<br/>
|
||||||
|
🟢 P.S: Thanks [Fabio Rehm](https://fabiorehm.com) for the amazing initial project.
|
||||||
|
|
||||||
|
--------
|
||||||
|
|
||||||
# vagrant-cachier
|
# vagrant-cachier
|
||||||
|
|
||||||
|
[](http://badge.fury.io/rb/vagrant-cachier) [](https://gitter.im/fgrehm/vagrant-cachier)
|
||||||
|
|
||||||
A [Vagrant](http://www.vagrantup.com/) plugin that helps you reduce the amount of
|
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
|
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)
|
package cache among similar VM instances. Kinda like [vagrant-apt_cache](https://github.com/avit/vagrant-apt_cache)
|
||||||
or [this magical snippet](http://gist.github.com/juanje/3797297) but targetting
|
or [this magical snippet](http://gist.github.com/juanje/3797297) but targeting
|
||||||
multiple package managers and Linux distros.
|
multiple package managers and Linux distros.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Make sure you have Vagrant 1.2+ and run:
|
Make sure you have Vagrant 1.4+ and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
vagrant plugin install vagrant-cachier
|
vagrant plugin install vagrant-cachier
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Quick start
|
||||||
|
|
||||||
The easiest way to set things up is just to enable [cache buckets auto detection](#auto-detect-supported-cache-buckets)
|
|
||||||
from within your `Vagrantfile`:
|
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.box = 'your-box'
|
config.vm.box = 'your-box'
|
||||||
config.cache.auto_detect = true
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
# If you are using VirtualBox, you might want to enable NFS for shared folders
|
# Configure cached packages to be shared between instances of the same base box.
|
||||||
# config.cache.enable_nfs = true
|
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
|
||||||
|
config.cache.scope = :box
|
||||||
|
|
||||||
|
# OPTIONAL: 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
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information about available buckets, please see the [configuration section](#configurations) below.
|
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's built in VirtualBox and Docker providers
|
||||||
* [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc)
|
* [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc)
|
||||||
* [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See
|
* [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See
|
||||||
[GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info)
|
[GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info)
|
||||||
|
* [vagrant-parallels](https://github.com/Parallels/vagrant-parallels)
|
||||||
|
* [vagrant-libvirt](https://github.com/pradels/vagrant-libvirt)
|
||||||
|
* [vagrant-kvm](https://github.com/adrahon/vagrant-kvm)
|
||||||
|
* _[Let us know if it is compatible with other providers!](https://github.com/fgrehm/vagrant-cachier/issues/new)_
|
||||||
|
|
||||||
## How does it work?
|
_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)_
|
||||||
Right now the plugin does not make any assumptions for you and you have to
|
|
||||||
configure things properly from your `Vagrantfile`. Please have a look at
|
|
||||||
the [available cache buckets](#available-cache-buckets) section below for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
Under the hood, the plugin will monkey patch `Vagrant::Builtin::Provision` and
|
|
||||||
will set things up for each configured cache bucket before running each defined
|
|
||||||
provisioner and after all provisioners are done. Before halting the machine,
|
|
||||||
it will 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.
|
|
||||||
|
|
||||||
Cache buckets will be available from `/tmp/vagrant-cachier` on your guest and
|
|
||||||
the appropriate folders will get symlinked to the right path _after_ the machine is
|
|
||||||
up but _right before_ it gets provisioned. We _could_ potentially do it on one go
|
|
||||||
and share bucket's folders directly to the right path if we were only using VirtualBox
|
|
||||||
since it shares folders _after_ booting the machine, but the LXC provider does that
|
|
||||||
_as part of_ the boot process (shared folders are actually `lxc-start` parameters)
|
|
||||||
and as of now we are not able to get some information that this plugin requires
|
|
||||||
about the guest machine before it is actually up and running.
|
|
||||||
|
|
||||||
Please keep in mind that this plugin won't do magic, if you are compiling things
|
|
||||||
during provisioning or manually downloading packages that does not fit into a
|
|
||||||
"cache bucket" you won't see that much of improvement.
|
|
||||||
|
|
||||||
|
|
||||||
## Benchmarks / shameless plug
|
|
||||||
|
|
||||||
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)
|
|
||||||
for the numbers I've got down here.
|
|
||||||
|
|
||||||
|
|
||||||
## Configurations
|
|
||||||
|
|
||||||
### Auto detect supported cache buckets
|
|
||||||
|
|
||||||
As described on the usage section above, you can enable automatic detection of
|
|
||||||
supported [cache "buckets"](#available-cache-buckets) by adding the code below to
|
|
||||||
your `Vagrantfile`:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
# ...
|
|
||||||
config.cache.auto_detect = true
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
This will make vagrant-cachier do its best to find out what is supported on the
|
|
||||||
guest machine and will set buckets accordingly.
|
|
||||||
|
|
||||||
### Cache scope
|
|
||||||
|
|
||||||
By default downloaded packages will get stored on a folder scoped to base boxes
|
|
||||||
under your `$HOME/.vagrant.d/cache`. The idea is to leverage the cache by allowing
|
|
||||||
downloaded packages to be reused across projects. So, if your `Vagrantfile` has
|
|
||||||
something like:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-box'
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
The cached files will be stored under `$HOME/.vagrant.d/cache/some-box`.
|
|
||||||
|
|
||||||
If you are on a [multi VM environment](http://docs.vagrantup.com/v2/multi-machine/index.html),
|
|
||||||
there is a huge chance that you'll end up having issues by sharing the same bucket
|
|
||||||
across different machines. For example, if you `apt-get install` from two machines
|
|
||||||
at "almost the same time" you are probably going to hit a `SystemError: Failed to lock /var/cache/apt/archives/lock`.
|
|
||||||
To work around that, you can set the scope to be based on machines:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-box'
|
|
||||||
config.cache.scope = :machine
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
This will tell vagrant-cachier to download packages to `.vagrant/machines/<machine-name>/<provider-name>/cache`
|
|
||||||
on your current project directory.
|
|
||||||
|
|
||||||
|
|
||||||
### Available cache "buckets"
|
|
||||||
|
|
||||||
#### System package managers
|
|
||||||
|
|
||||||
##### APT
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-debian-box'
|
|
||||||
config.cache.enable :apt
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt/archives`.
|
|
||||||
|
|
||||||
_Please note that to avoid re-downloading packages, you should avoid `apt-get clean`
|
|
||||||
as much as possible in order to make a better use of the cache, even if you are
|
|
||||||
packaging a box_
|
|
||||||
|
|
||||||
##### Yum
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-centos-box'
|
|
||||||
config.cache.enable :yum
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
Used by CentOS guests, will get configured under guest's `/var/cache/yum`. It will
|
|
||||||
also [make sure](lib/vagrant-cachier/bucket/yum.rb#L20) that `keepcache` is set to
|
|
||||||
`1` on guest's `/etc/yum.conf`.
|
|
||||||
|
|
||||||
##### Pacman
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-arch-linux-box'
|
|
||||||
config.cache.enable :pacman
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
Used by Arch Linux, will get configured under guest's `/var/cache/pacman/pkg`.
|
|
||||||
|
|
||||||
#### Chef
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-box-using-chef-provisioner'
|
|
||||||
config.cache.enable :chef
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
When a Chef provisioner is detected, this bucket caches the default
|
|
||||||
`file_cache_path` directory, `/var/chef/cache`. Requires Vagrant 1.2.4+.
|
|
||||||
|
|
||||||
#### RubyGems
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-box-with-ruby-installed'
|
|
||||||
config.cache.enable :gem
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
Compatible with probably with any type of guest distro, will hook into the `cache`
|
|
||||||
folder under the result of running `gem env gemdir` as the default SSH user (usualy
|
|
||||||
`vagrant`) on your guest. If you use rbenv / rvm on the guest machine, make sure
|
|
||||||
it is already installed before enabling the bucket, otherwise you won't benefit
|
|
||||||
from this plugin.
|
|
||||||
|
|
||||||
#### RVM
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.box = 'some-box-with-rvm-installed'
|
|
||||||
config.cache.enable :rvm
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
Compatible with probably with any type of linux guest distro, will hook into the `cache`
|
|
||||||
folder under the result of running `rvm info` as the default SSH user (usualy
|
|
||||||
`vagrant`) on your guest. If you use rvm on the guest machine, make sure
|
|
||||||
it is already installed before enabling the bucket, otherwise you won't benefit
|
|
||||||
from this plugin.
|
|
||||||
|
|
||||||
## Finding out disk space used by buckets
|
|
||||||
|
|
||||||
_TODO_
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ vagrant cache stats
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Cleaning up cache buckets
|
|
||||||
|
|
||||||
_TODO_
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ vagrant cache clean apt
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
SITE
|
SITE
|
||||||
remote: http://community.opscode.com/api/v1
|
remote: http://community.opscode.com/api/v1
|
||||||
specs:
|
specs:
|
||||||
chef_handler (1.1.4)
|
java (1.19.2)
|
||||||
java (1.12.0)
|
|
||||||
windows (>= 0.0.0)
|
|
||||||
windows (1.10.0)
|
|
||||||
chef_handler (>= 0.0.0)
|
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
java (>= 0)
|
java (>= 0)
|
||||||
|
|
144
development/Vagrantfile
vendored
144
development/Vagrantfile
vendored
|
@ -1,78 +1,132 @@
|
||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
Vagrant.require_plugin 'vagrant-cachier'
|
|
||||||
Vagrant.require_plugin 'vagrant-librarian-chef'
|
|
||||||
Vagrant.require_plugin 'vagrant-lxc'
|
|
||||||
Vagrant.require_plugin 'vagrant-omnibus'
|
|
||||||
Vagrant.require_plugin 'vagrant-pristine'
|
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'#, nfs: true
|
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
|
||||||
|
|
||||||
config.cache.scope = :machine
|
config.cache.scope = :machine
|
||||||
config.cache.auto_detect = true
|
config.cache.auto_detect = true
|
||||||
config.cache.enable_nfs = true
|
config.cache.synced_folder_opts = { type: :nfs }
|
||||||
|
|
||||||
config.vm.provider :virtualbox do |_, vb|
|
config.vm.provider :virtualbox do |vb|
|
||||||
vb.vm.network :private_network, ip: "192.168.50.123"
|
vb.customize [ "modifyvm", :id, "--memory", 256, "--cpus", "1" ]
|
||||||
end
|
end
|
||||||
|
|
||||||
config.omnibus.chef_version = :latest
|
config.vm.provider :lxc do |lxc|
|
||||||
config.vm.provision :chef_solo do |chef|
|
lxc.customize 'aa_profile', 'unconfined'
|
||||||
chef.add_recipe "java::oracle"
|
|
||||||
chef.json = {
|
|
||||||
:java => {
|
|
||||||
:oracle => {
|
|
||||||
:accept_oracle_download_terms => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
debian_like_configs = lambda do |debian|
|
configure_private_network = lambda do |node, suffix|
|
||||||
debian.vm.provision :shell, inline: '
|
node.vm.network :private_network, ip: "192.168.50.#{suffix}"
|
||||||
if ! (which bundle > /dev/null); then
|
end
|
||||||
sudo gem install bundler --no-ri --no-rdoc
|
|
||||||
sudo apt-get install -y build-essential libffi-dev ruby1.9.1-dev git
|
initial_debian_setup = lambda do |debian, git_pkg = 'git'|
|
||||||
cd /vagrant && bundle
|
debian.vm.provision :shell, inline: "apt-get update && apt-get install -y #{git_pkg} php5-cli curl wget htop"
|
||||||
fi'
|
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
|
end
|
||||||
|
|
||||||
config.vm.define :ubuntu do |ubuntu|
|
config.vm.define :ubuntu do |ubuntu|
|
||||||
ubuntu.vm.box = "quantal64"
|
ubuntu.vm.box = "raring64"
|
||||||
debian_like_configs.call ubuntu
|
ubuntu.vm.provider :lxc do |_, override|
|
||||||
|
override.vm.box = 'fgrehm/raring64-lxc'
|
||||||
|
end
|
||||||
|
|
||||||
|
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 "cachier::default"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define :lucid do |lucid|
|
||||||
|
lucid.vm.box = "lucid64"
|
||||||
|
# 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
|
end
|
||||||
|
|
||||||
config.vm.define :debian do |debian|
|
config.vm.define :debian do |debian|
|
||||||
debian.vm.box = "squeeze64"
|
debian.vm.box = "squeeze64"
|
||||||
debian.vm.box_url = 'http://f.willianfernandes.com.br/vagrant-boxes/DebianSqueeze64.box'
|
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
|
end
|
||||||
|
|
||||||
config.vm.define :centos do |centos|
|
config.vm.define :centos do |centos|
|
||||||
centos.vm.box = 'centos6_64'
|
centos.vm.box = 'centos6_64'
|
||||||
centos.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box'
|
centos.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box'
|
||||||
|
configure_private_network.call centos, 13
|
||||||
|
|
||||||
centos.vm.provision :shell, inline: '
|
centos.vm.provision :shell, inline: '
|
||||||
if ! (which bundle > /dev/null); then
|
(
|
||||||
time sudo gem install bundler --no-ri --no-rdoc
|
mkdir -p /tmp/epel
|
||||||
time sudo yum install -y libffi-devel ruby-devel git
|
cd /tmp/epel
|
||||||
fi'
|
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
|
end
|
||||||
|
|
||||||
config.vm.define :arch do |arch|
|
config.vm.define :arch do |arch|
|
||||||
arch.vm.box = 'arch64'
|
arch.vm.box = 'arch64'
|
||||||
arch.vm.box_url = 'http://vagrant.pouss.in/archlinux_2012-07-02.box'
|
arch.vm.box_url = 'https://dl.dropboxusercontent.com/u/6750592/Arch_Linux_2013.11_x64.box'
|
||||||
arch.vm.provision :shell, inline: '
|
# Disable NFS
|
||||||
if ! (which bundle > /dev/null); then
|
arch.cache.synced_folder_opts = { }
|
||||||
time sudo gem install bundler --no-ri --no-rdoc
|
|
||||||
time sudo pacman -Syu --noconfirm libffi git
|
arch.vm.provision :shell, inline: 'pacman -Syu --noconfirm libffi git ruby && gem install bundler'
|
||||||
fi'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.provision :shell, inline: '
|
config.vm.define :opensuse do |suse|
|
||||||
if ! [ -d /home/vagrant/.rvm ]; then
|
suse.vm.box = 'opensuse-12'
|
||||||
HOME=/home/vagrant su -p vagrant -c "curl -L https://get.rvm.io | bash -s stable"
|
suse.vm.box_url = 'http://sourceforge.net/projects/opensusevagrant/files/12.3/opensuse-12.3-64.box/download'
|
||||||
fi
|
# Disable NFS
|
||||||
'
|
suse.cache.synced_folder_opts = { }
|
||||||
|
|
||||||
|
suse.vm.provision :shell, inline: 'time zypper install -y git'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
4
development/cookbooks/cachier/recipes/default.rb
Normal file
4
development/cookbooks/cachier/recipes/default.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
zip_filepath = "#{Chef::Config['file_cache_path']}/vagrant-cachier.tar.gz"
|
||||||
|
zip_url = "https://github.com/fgrehm/vagrant-cachier/archive/v0.6.0.tar.gz"
|
||||||
|
|
||||||
|
remote_file(zip_filepath) { source zip_url }
|
28
docs/benchmarks.md
Normal file
28
docs/benchmarks.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Benchmarks
|
||||||
|
|
||||||
|
During the early days of this plugin, [@fgrehm](https://github.com/fgrehm) wrote
|
||||||
|
a [blog post](http://fabiorehm.com/blog/2013/05/24/stop-wasting-bandwidth-with-vagrant-cachier#show_me_the_numbers)
|
||||||
|
with some benchmarks on the time that was cut down by using the plugin. If you
|
||||||
|
are interested on the numbers only, the VMs tested were one of vagrant-lxc's
|
||||||
|
Ubuntu [dev boxes](https://github.com/fgrehm/vagrant-lxc/wiki/Development#using-virtualbox-for-development),
|
||||||
|
[rails-dev-box](https://github.com/rails/rails-dev-box), his own [rails-base-box](https://github.com/fgrehm/rails-base-box)
|
||||||
|
and Discourse's [dev box](https://github.com/discourse/discourse/blob/master/Vagrantfile)
|
||||||
|
|
||||||
|
| | First provision | Second provision | Diff. | APT cache |
|
||||||
|
| --- | :---: | :---: | :---: | :---: |
|
||||||
|
| rails-dev-box | 4m45s | 3m20s | ~29% | 66mb |
|
||||||
|
| rails-base-box | 11m56s | 7m54s | ~34% | 77mb |
|
||||||
|
| vagrant-lxc | 10m16s | 5m9s | ~50% | 124mb |
|
||||||
|
| discourse | 1m41s | 49s | ~51% | 62mb |
|
||||||
|
<br>
|
||||||
|
_Please note that the tests were made on May 24th 2013 and nowadays they might
|
||||||
|
be a bit different_
|
||||||
|
|
||||||
|
<br>
|
||||||
|
Some people have shared their numbers on Twitter and had experienced even better
|
||||||
|
results:
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
<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>
|
30
docs/buckets/apt-cacher.md
Normal file
30
docs/buckets/apt-cacher.md
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# APT-CACHER
|
||||||
|
|
||||||
|
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt-cacher-ng`
|
||||||
|
and only works with NFS-shared folders since `vboxsf` is enforcing `vagrant`-user and `apt-cacher`
|
||||||
|
is running under `apt-cacher-ng` user.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-debian-box'
|
||||||
|
config.cache.enable :apt_cacher
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
One use case for this bucket is if you are using containers inside your VMs, e.g
|
||||||
|
VirtualBox -> LXC. This would allow you to reuse packages without sharing folder
|
||||||
|
inside VirtualBox:
|
||||||
|
|
||||||
|
# install apt-cacher on (Host)-VM
|
||||||
|
$ sudo apt-get install apt-cacher-ng
|
||||||
|
|
||||||
|
# get the IP for eth0 interface
|
||||||
|
$ ifconfig eth0 |grep "inet addr"|awk '{print $2}' |cut -c6-20
|
||||||
|
|
||||||
|
# configure mirror on for your docker/LXC instances:
|
||||||
|
$ echo 'Acquire::http { Proxy "http://X.X.X.X:3142"; };' > /etc/apt/apt.conf.d/10mirror
|
||||||
|
|
||||||
|
# check, if working by tailing log on (Host)-VM, while installing packages on (Guest)-VMs
|
||||||
|
$ tail -f /var/log/apt-cacher-ng/apt-cacher.log
|
27
docs/buckets/apt-lists.md
Normal file
27
docs/buckets/apt-lists.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# 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
|
||||||
|
```
|
||||||
|
|
||||||
|
## Heads up!
|
||||||
|
|
||||||
|
This bucket is automatically disabled for Windows hosts, please have a look at
|
||||||
|
the following issues for more information:
|
||||||
|
|
||||||
|
* https://github.com/fgrehm/vagrant-cachier/issues/106
|
||||||
|
* https://github.com/fgrehm/vagrant-cachier/issues/109
|
||||||
|
* https://github.com/fgrehm/vagrant-cachier/issues/113
|
17
docs/buckets/apt.md
Normal file
17
docs/buckets/apt.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# APT
|
||||||
|
|
||||||
|
Used by Debian-like Linux distros, will get configured under guest's `/var/cache/apt/archives`.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-debian-box'
|
||||||
|
config.cache.enable :apt
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
_Please note that to avoid re-downloading packages, you should avoid `apt-get clean`
|
||||||
|
as much as possible in order to make a better use of the cache, even if you are
|
||||||
|
packaging a box since the downloaded packages are actually stored on the host
|
||||||
|
machine._
|
13
docs/buckets/bower.md
Normal file
13
docs/buckets/bower.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# [Bower](http://bower.io/)
|
||||||
|
|
||||||
|
Compatible with probably any type of linux guest distro, will cache guests'
|
||||||
|
`$HOME/.cache/bower` if bower is detected.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-bower-installed'
|
||||||
|
config.cache.enable :bower
|
||||||
|
end
|
||||||
|
```
|
13
docs/buckets/chef.md
Normal file
13
docs/buckets/chef.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Chef
|
||||||
|
|
||||||
|
When a Chef provisioner is detected, this bucket caches the default
|
||||||
|
`file_cache_path` directory, `/var/chef/cache`. Requires Vagrant 1.2.4+.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-using-chef-provisioner'
|
||||||
|
config.cache.enable :chef
|
||||||
|
end
|
||||||
|
```
|
18
docs/buckets/chef_rubygems.md
Normal file
18
docs/buckets/chef_rubygems.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Chef RubyGems
|
||||||
|
|
||||||
|
When a Chef installation is detected, this bucket caches its embedded gems.
|
||||||
|
Most of these gems are part of the Chef omnibus package but sometimes cookbooks
|
||||||
|
need to install extra gems to run within the context of a Chef recipe using the
|
||||||
|
`chef_gem` resource.
|
||||||
|
|
||||||
|
The embedded Chef gem location is returned by running the
|
||||||
|
`/opt/chef/embedded/bin/gem env gemdir` command.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-using-chef-provisioner'
|
||||||
|
config.cache.enable :chef_gem
|
||||||
|
end
|
||||||
|
```
|
13
docs/buckets/composer.md
Normal file
13
docs/buckets/composer.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# [Composer](http://getcomposer.org/)
|
||||||
|
|
||||||
|
Compatible with probably any type of linux guest distro, will cache guests'
|
||||||
|
`$HOME/.composer/cache` if PHP is detected.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-php-installed'
|
||||||
|
config.cache.enable :composer
|
||||||
|
end
|
||||||
|
```
|
20
docs/buckets/dnf.md
Normal file
20
docs/buckets/dnf.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# DNF
|
||||||
|
|
||||||
|
Used by Fedora guests, will get configured under guest's `/var/cache/dnf`. It will
|
||||||
|
also [make sure](lib/vagrant-cachier/bucket/dnf.rb#L20) that `keepcache` is set to
|
||||||
|
`1` on guest's `/etc/dnf/dnf.conf`.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-fedora-box'
|
||||||
|
config.cache.enable :dnf
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### :warning: Notice about Windows hosts :warning:
|
||||||
|
|
||||||
|
In case this bucket is enabled and a Windows host is in use, you might see an
|
||||||
|
ugly stacktrace as described on [this comment](https://github.com/fgrehm/vagrant-cachier/issues/117#issuecomment-50548393)
|
||||||
|
if some DNF repository is not available during provisioning.
|
46
docs/buckets/generic.md
Normal file
46
docs/buckets/generic.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Generic
|
||||||
|
|
||||||
|
This bucket is never enabled by default. You have to enable it explicitly like
|
||||||
|
this:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.cache.enable :generic, { :cache_dir => "/var/cache/some" }
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
The `:cache_dir` parameter is required. It specifies the directory on the guest
|
||||||
|
that will be cached under the "/tmp/vagrant-cache/generic" bucket.
|
||||||
|
|
||||||
|
You may enable more than one generic bucket by giving them different names,
|
||||||
|
like this:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.cache.enable :generic, {
|
||||||
|
"one" => { cache_dir: "/var/cache/one" },
|
||||||
|
"two" => { cache_dir: "/var/cache/two" },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
In this case you get two buckets called "one" and "two" under the guest's
|
||||||
|
`/tmp/vagrant-cache` directory.
|
||||||
|
|
||||||
|
The Generic bucket is useful if you want to implement a caching mechanism by
|
||||||
|
hand. For instance, if you want to cache your wget downloads under
|
||||||
|
`/var/cache/wget` you can do this:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.cache.enable :generic, {
|
||||||
|
"wget" => { cache_dir: "/var/cache/wget" },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, you invoke wget like this:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget -N -P /var/cache/wget URL
|
||||||
|
```
|
18
docs/buckets/npm.md
Normal file
18
docs/buckets/npm.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# [npm](https://npmjs.org/)
|
||||||
|
|
||||||
|
Compatible with probably any type of linux guest distro, will hook into npm's
|
||||||
|
cache directory under the result of running `npm config get cache` as
|
||||||
|
the default SSH user (usually `vagrant`) on your guest.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-nodejs-installed'
|
||||||
|
config.cache.enable :npm
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use [nvm](https://github.com/creationix/nvm) / [n](https://github.com/visionmedia/n)
|
||||||
|
on the guest machine, make sure it is already installed before enabling
|
||||||
|
the bucket, otherwise you won't benefit from this plugin.
|
12
docs/buckets/pacman.md
Normal file
12
docs/buckets/pacman.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Pacman
|
||||||
|
|
||||||
|
Used by Arch Linux, will get configured under guest's `/var/cache/pacman/pkg`.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-arch-linux-box'
|
||||||
|
config.cache.enable :pacman
|
||||||
|
end
|
||||||
|
```
|
15
docs/buckets/pip.md
Normal file
15
docs/buckets/pip.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# [pip](https://pip.pypa.io/)
|
||||||
|
|
||||||
|
Compatible with probably any type of linux guest distro, will hook into pip's
|
||||||
|
http and wheels cache directory under `$HOME/.cache/pip/http` and `$HOME/.cache/pip/wheels` as
|
||||||
|
the default SSH user (usually `vagrant`) on your guest.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-pip-installed'
|
||||||
|
config.cache.enable :pip
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
22
docs/buckets/rubygems.md
Normal file
22
docs/buckets/rubygems.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# RubyGems
|
||||||
|
|
||||||
|
Compatible with probably with any type of guest distro, will hook into the `cache`
|
||||||
|
folder under the result of running `gem env gemdir` as the default SSH user (usualy
|
||||||
|
`vagrant`) on your guest. If you use rbenv / rvm on the guest machine, make sure
|
||||||
|
it is already installed before enabling the bucket, otherwise you won't benefit
|
||||||
|
from this plugin.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-ruby-installed'
|
||||||
|
config.cache.enable :gem
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Heads up about `bundle install --deployment`
|
||||||
|
|
||||||
|
Please note that when the `--deployment` flag is passed on to `bundle install`
|
||||||
|
your gems **will not be cached** since bundler ends up skipping the default gem
|
||||||
|
cache dir. For more information about this, please check [GH-62](https://github.com/fgrehm/vagrant-cachier/issues/62).
|
59
docs/buckets/rvm.md
Normal file
59
docs/buckets/rvm.md
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# [rvm](https://rvm.io/)
|
||||||
|
|
||||||
|
Compatible with probably with any type of linux guest distro, will hook into the
|
||||||
|
`cache` folder under the result of running rvm info as the default SSH user (usualy
|
||||||
|
`vagrant`) on your guest. If you use rvm on the guest machine, make sure it is
|
||||||
|
already installed before enabling the bucket, otherwise you won't benefit from
|
||||||
|
this plugin.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box-with-rvm-installed'
|
||||||
|
config.cache.enable :gem
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Heads up!
|
||||||
|
|
||||||
|
If you are installing rvm, rubies and gems on a single provisioning step, **you
|
||||||
|
will not benefit from this bucket**. There is absolutely no way we can "magically"
|
||||||
|
hook into your provisioning scripts to configure things for leveraging the cache.
|
||||||
|
|
||||||
|
For instance, the following shell provisioner **will result in no package cached at
|
||||||
|
all**:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
config.vm.provision :shell, privileged: false, inline: %[
|
||||||
|
curl -L https://get.rvm.io | bash -s stable
|
||||||
|
rvm install 1.9.3
|
||||||
|
rvm use 1.9.3 --default
|
||||||
|
cd /path/to/project
|
||||||
|
bundle install
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
To work around that you can either configure things by hand on your provisioning
|
||||||
|
scripts or you can enable automatic bucket detection and split your scripts into
|
||||||
|
multiple stages:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
# Install RVM so that Ruby tarballs are cached
|
||||||
|
config.vm.provision :shell, privileged: false, inline: %[
|
||||||
|
curl -L https://get.rvm.io | bash -s stable
|
||||||
|
]
|
||||||
|
|
||||||
|
# Install Ruby 1.9.3 making use of the RVM cache and configure the RubyGems
|
||||||
|
# cache afterwards
|
||||||
|
config.vm.provision :shell, privileged: false, inline: %[
|
||||||
|
rvm install 1.9.3
|
||||||
|
rvm use 1.9.3 --default
|
||||||
|
]
|
||||||
|
|
||||||
|
# Install gems making use of the RubyGems cache
|
||||||
|
config.vm.provision :shell, privileged: false, inline: %[
|
||||||
|
cd /path/to/project
|
||||||
|
bundle install
|
||||||
|
]
|
||||||
|
```
|
20
docs/buckets/yum.md
Normal file
20
docs/buckets/yum.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Yum
|
||||||
|
|
||||||
|
Used by CentOS guests, will get configured under guest's `/var/cache/yum`. It will
|
||||||
|
also [make sure](lib/vagrant-cachier/bucket/yum.rb#L20) that `keepcache` is set to
|
||||||
|
`1` on guest's `/etc/yum.conf`.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-centos-box'
|
||||||
|
config.cache.enable :yum
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### :warning: Notice about Windows hosts :warning:
|
||||||
|
|
||||||
|
In case this bucket is enabled and a Windows host is in use, you might see an
|
||||||
|
ugly stacktrace as described on [this comment](https://github.com/fgrehm/vagrant-cachier/issues/117#issuecomment-50548393)
|
||||||
|
if some Yum repository is not available during provisioning.
|
14
docs/buckets/zypper.md
Normal file
14
docs/buckets/zypper.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Zypper
|
||||||
|
|
||||||
|
Used by SuSE guests, will get configured under guest's `/var/cache/zypp/packages`. It will
|
||||||
|
also [make sure](lib/vagrant-cachier/bucket/zypper.rb#L20) that `keep-packages` is enabled
|
||||||
|
for all repositories.
|
||||||
|
|
||||||
|
To manually enable it:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-suse-box'
|
||||||
|
config.cache.enable :zypper
|
||||||
|
end
|
||||||
|
```
|
64
docs/development.md
Normal file
64
docs/development.md
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
# Development
|
||||||
|
|
||||||
|
## Installing from sources
|
||||||
|
|
||||||
|
If you want to install the plugin from sources:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/fgrehm/vagrant-cachier.git
|
||||||
|
cd vagrant-cachier
|
||||||
|
bundle install
|
||||||
|
bundle exec rake build
|
||||||
|
vagrant plugin install pkg/vagrant-cachier-VERSION.gem
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Sanity checks
|
||||||
|
|
||||||
|
While we don't get to implement some proper unit testing, there are some basic [Bats](https://github.com/sstephenson/bats)
|
||||||
|
tests that basically acts as a [sanity check](https://github.com/fgrehm/vagrant-cachier/blob/master/spec/acceptance/sanity_check.bats)
|
||||||
|
that you can run with `bats spec/acceptance` in case you are planning to submit a
|
||||||
|
Pull Request. Just keep in mind that it might take a while to run if you are
|
||||||
|
using the default VirtualBox provider.
|
||||||
|
|
||||||
|
|
||||||
|
## How to create a new bucket?
|
||||||
|
|
||||||
|
The concept of a cache _bucket_ is pretty easy to understand, we basically
|
||||||
|
symlink a folder under the guest's `/tmp/vagrant-cache` into the folder where
|
||||||
|
other tools keep downloaded packages. For example, in the case of the
|
||||||
|
[apt bucket](buckets/apt), we symlink `/var/cache/apt/archives` to
|
||||||
|
`/tmp/vagrant-cache/apt` so that `.deb` packages downloaded with `apt-get install`
|
||||||
|
can be reused when bringing machines up from scratch.
|
||||||
|
|
||||||
|
If you want to see some other package manager supported, you'll first need to
|
||||||
|
know if it has some sort of caching in place, where does it get stored and if
|
||||||
|
it needs some extra configuration. For some managers that path will be fixed
|
||||||
|
(like the canonical apt bucket), for others you might need to read some
|
||||||
|
configuration by [running a command](https://github.com/fgrehm/vagrant-cachier/blob/master/lib/vagrant-cachier/cap/linux/rvm_path.rb#L10)
|
||||||
|
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)
|
||||||
|
on the guest (like the [yum](buckets/yum) bucket).
|
||||||
|
|
||||||
|
There's currently a lot of duplication around the "installation" of cache buckets
|
||||||
|
so there's plenty of source code for you to read in order to understand how
|
||||||
|
things work under the hood but if you don't feel comfortable reading / writing
|
||||||
|
Ruby code you can provide a high level overview of how to do things using plain
|
||||||
|
old bash.
|
||||||
|
|
||||||
|
For example, if you were to explain how to set up the rvm bucket, the script
|
||||||
|
below should give vagrant-cachier maintainers an overview of how to set things
|
||||||
|
up:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check is rvm is installed
|
||||||
|
if ! $(rvm info > /dev/null); then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it is installed, read the cache dir
|
||||||
|
RVM_CACHE="${rvm_path}/archives"
|
||||||
|
|
||||||
|
# "Install" the bucket!
|
||||||
|
mkdir -p /tmp/vagrant-cache/rvm/archives
|
||||||
|
ln -s /tmp/vagrant-cache/rvm/archives $RVM_CACHE
|
||||||
|
```
|
31
docs/how-does-it-work.md
Normal file
31
docs/how-does-it-work.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
## How does it work?
|
||||||
|
|
||||||
|
On vagrant-cachier's _"jargon"_, cached packages are kept in _cache buckets_.
|
||||||
|
Those _buckets_ are basically directories that are shared between the host machine
|
||||||
|
and VMs that are kept around between `vagrant destroy`s. Each _bucket_ (or synced
|
||||||
|
folder if you prefer) is meant to cache specific types of packages, like [apt](buckets/apt)'s
|
||||||
|
`.deb`s or [RubyGems](buckets/rubygems) `.gem`s. Please have a look at the
|
||||||
|
"Available Buckets" menu above for more information on each bucket.
|
||||||
|
|
||||||
|
Regarding configurations, right now the plugin does not make any assumptions for
|
||||||
|
you and you have to configure things properly from your `Vagrantfile`. In other
|
||||||
|
words, _the plugin is disabled by default_.
|
||||||
|
|
||||||
|
Cache buckets will always be available from `/tmp/vagrant-cache` on your guest and
|
||||||
|
the appropriate folders will get symlinked to the right path _after_ the machine is
|
||||||
|
up but _right before_ it gets provisioned. We _could_ potentially do it on one go
|
||||||
|
and share bucket's folders directly to the right path if we were only using VirtualBox
|
||||||
|
because it shares folders _after_ booting the machine but the LXC provider does that
|
||||||
|
_as part of_ the boot process (synced folders are actually `lxc-start` parameters)
|
||||||
|
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 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
|
||||||
|
won't see that much of improvement.
|
68
docs/index.md
Normal file
68
docs/index.md
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# vagrant-cachier
|
||||||
|
|
||||||
|
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)
|
||||||
|
or [this magical snippet](http://gist.github.com/juanje/3797297) but targetting
|
||||||
|
multiple package managers and Linux distros.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Make sure you have Vagrant 1.4+ and run:
|
||||||
|
|
||||||
|
```
|
||||||
|
vagrant plugin install vagrant-cachier
|
||||||
|
```
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
The easiest way to set things up is just to enable [cache buckets auto detection](usage)
|
||||||
|
from within your `Vagrantfile`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'your-box'
|
||||||
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
|
# Configure cached packages to be shared between instances of the same base box.
|
||||||
|
# More info on the "Usage" link above
|
||||||
|
config.cache.scope = :box
|
||||||
|
|
||||||
|
# OPTIONAL: 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
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information please check out the links on the menu above.
|
||||||
|
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
1. Fork it
|
||||||
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
|
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
|
146
docs/template.html
Normal file
146
docs/template.html
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{NAME}} :: viewdocs.io</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/3.0.2/yeti/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="http://fgrehm.github.io/viewdocs-yeti/stylesheets/pygment_trac.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
/* The html and body elements cannot have any padding or margin. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper for page content to push down footer */
|
||||||
|
#wrap {
|
||||||
|
min-height: 100%;
|
||||||
|
height: auto;
|
||||||
|
/* Negative indent footer by its height */
|
||||||
|
margin: 0 auto -60px;
|
||||||
|
/* Pad bottom by footer height */
|
||||||
|
padding: 0 0 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the fixed height of the footer here */
|
||||||
|
footer {
|
||||||
|
height: 60px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
padding-top: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer p {
|
||||||
|
clear: left;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wrap > .container {
|
||||||
|
padding-top: 60px;
|
||||||
|
}
|
||||||
|
.navbar-nav>li>iframe {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="wrap">
|
||||||
|
<div class="navbar navbar-default navbar-fixed-top">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a href="/{{NAME}}" class="navbar-brand">{{NAME}}</a>
|
||||||
|
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="navbar-collapse collapse" id="navbar-main">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li>
|
||||||
|
<a href="usage">Usage</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="how-does-it-work">How does it work?</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="benchmarks">Benchmarks</a>
|
||||||
|
</li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Available Buckets <span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a tabindex="-1" href="buckets/generic">Generic</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/apt">APT</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/apt-lists">apt-lists</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/apt-cacher">apt-cacher</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/chef">Chef</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/chef_rubygems">Chef Gems</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/composer">Composer</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/dnf">DNF</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/bower">Bower</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/pacman">Pacman</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/npm">npm</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/rubygems">RubyGems</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/rvm">rvm</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/yum">Yum</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/zypper">Zypper</a></li>
|
||||||
|
<li><a tabindex="-1" href="buckets/pip">pip</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="development">Development</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<li><a href="https://gitter.im/fgrehm/vagrant-cachier" target="_blank">Chat</li>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="nav navbar-nav navbar-right visible-md visible-lg">
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
{{CONTENT}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<p>Hosted on <a href="http://viewdocs.io">http://viewdocs.io</a>.</p>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="//oss.maxcdn.com/libs/jquery/2.0.3/jquery.min.js"></script>
|
||||||
|
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
ga('create', 'UA-38687494-5', 'viewdocs.io');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
152
docs/usage.md
Normal file
152
docs/usage.md
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Being nice to others
|
||||||
|
|
||||||
|
It is a good practice to wrap plugin specific configuration with `has_plugin?` checks
|
||||||
|
so the user's Vagrantfiles do not break if `vagrant-cachier` is uninstalled or
|
||||||
|
the Vagrantfile is shared with people that don't have the plugin installed:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
# ...
|
||||||
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
|
# ... vagrant-cachier configs ...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cache scope
|
||||||
|
|
||||||
|
This is the only required configuration for the plugin to work and should be present
|
||||||
|
on your project's specific `Vagrantfile` or on your `~/.vagrant.d/Vagrantfile` in
|
||||||
|
order to enable it.
|
||||||
|
|
||||||
|
### `:box` scope
|
||||||
|
|
||||||
|
By setting `cache.scope` to `:box`, downloaded packages will get stored on a folder
|
||||||
|
scoped to base boxes under your `~/.vagrant.d/cache`. The idea is to leverage the
|
||||||
|
cache by allowing downloaded packages to be reused across projects. So, if your
|
||||||
|
`Vagrantfile` has something like:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box'
|
||||||
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
|
config.cache.scope = :box
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
The cached files will be stored under `$HOME/.vagrant.d/cache/some-box`.
|
||||||
|
|
||||||
|
### `:machine` scope
|
||||||
|
|
||||||
|
If you are on a [multi VM environment](http://docs.vagrantup.com/v2/multi-machine/index.html),
|
||||||
|
there is a huge chance that you'll end up having issues by sharing the same bucket
|
||||||
|
across different machines. For example, if you `apt-get install` from two machines
|
||||||
|
at "almost the same time" you are probably going to hit a _"SystemError: Failed to
|
||||||
|
lock /var/cache/apt/archives/lock"_. To work around that, you can set the scope
|
||||||
|
to be based on machines:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box'
|
||||||
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
|
config.cache.scope = :machine
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
This will tell vagrant-cachier to download packages to `.vagrant/machines/<machine-name>/cache`
|
||||||
|
on your current project directory.
|
||||||
|
|
||||||
|
## Cache buckets automatic detection
|
||||||
|
|
||||||
|
This is the easiest way to get started with plugin and is enabled by default.
|
||||||
|
Under the hood, `vagrant-cachier` does its best to find out what is supported on the
|
||||||
|
guest machine and will set buckets accordingly.
|
||||||
|
|
||||||
|
If you want that behavior to be disabled, you can set `cache.auto_detect` to `false`
|
||||||
|
from your Vagrantfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = 'some-box'
|
||||||
|
if Vagrant.has_plugin?("vagrant-cachier")
|
||||||
|
config.cache.scope = :machine # or :box
|
||||||
|
config.cache.auto_detect = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Enable buckets as needed
|
||||||
|
|
||||||
|
If for whatever reason you need to have a fined grained control over what buckets
|
||||||
|
are configured, you can do so by "cherry picking" them on your `Vagrantfile`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.cache.auto_detect = false
|
||||||
|
config.cache.enable :apt
|
||||||
|
config.cache.enable :gem
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
_Please refer to the "Available Buckets" menu above to find out which buckets
|
||||||
|
are supported._
|
||||||
|
|
||||||
|
## Custom cache buckets synced folders options
|
||||||
|
|
||||||
|
For fine grained control over the cache bucket synced folder options you can use
|
||||||
|
the `synced_folder_opts` config. That's useful if, for example, you are using
|
||||||
|
VirtualBox and want to enable NFS for improved performance:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
Please referer to http://docs.vagrantup.com/v2/synced-folders/basic_usage.html for
|
||||||
|
more information about the supported parameters.
|
||||||
|
|
||||||
|
## Finding out disk space used by buckets
|
||||||
|
|
||||||
|
At some point we might implement a `vagrant cache stats` command that will give you that
|
||||||
|
information, but while that does not get implemented you can run the code below
|
||||||
|
if you are on a Linux machine:
|
||||||
|
|
||||||
|
```
|
||||||
|
# scope = :box (default)
|
||||||
|
$ du -h -d0 $HOME/.vagrant.d/cache
|
||||||
|
405M /home/user/.vagrant.d/cache/precise64
|
||||||
|
1.1G /home/user/.vagrant.d/cache/raring64
|
||||||
|
448M /home/user/.vagrant.d/cache/quantal64
|
||||||
|
|
||||||
|
# scope = :machine
|
||||||
|
$ du -h -d0 .vagrant/machines/*/cache
|
||||||
|
16K .vagrant/machines/precise/cache
|
||||||
|
90M .vagrant/machines/quantal/cache
|
||||||
|
210M .vagrant/machines/raring/cache
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cleaning up cache buckets
|
||||||
|
|
||||||
|
At some point we might implement a `vagrant cache clean [bucket-name]` command that will
|
||||||
|
take care of things for you, but while that does not get implemented you can run
|
||||||
|
the code below if you are on a Linux machine:
|
||||||
|
|
||||||
|
```
|
||||||
|
# scope = :box (default)
|
||||||
|
$ rm -rf $HOME/.vagrant.d/cache/<box-name>/<optional-bucket-name>
|
||||||
|
|
||||||
|
# scope = :machine
|
||||||
|
$ rm -rf .vagrant/machines/<machine-name>/cache/<optional-bucket-name>
|
||||||
|
```
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'timeout'
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Cachier
|
module Cachier
|
||||||
class Action
|
class Action
|
||||||
|
@ -8,29 +10,54 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
@env = env
|
@env = env
|
||||||
|
@machine = env[:machine]
|
||||||
|
|
||||||
if env[:machine].state.id == :running && symlinks.any?
|
if symlinks.any?
|
||||||
env[:ui].info I18n.t('vagrant_cachier.cleanup')
|
env[:ui].info I18n.t('vagrant_cachier.cleanup')
|
||||||
symlinks.each do |symlink|
|
if sshable?
|
||||||
remove_symlink symlink
|
symlinks.each do |symlink|
|
||||||
|
remove_symlink symlink
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
File.delete env[:machine].data_dir.join('cache_dirs').to_s
|
File.delete @machine.data_dir.join('cache_dirs').to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call env
|
@app.call env
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sshable?
|
||||||
|
return if @machine.state.id != :running
|
||||||
|
|
||||||
|
# By default Vagrant will keep trying [1] to ssh connect to the VM for
|
||||||
|
# a long and we've got to prevent that from happening, so we just wait
|
||||||
|
# a few seconds and assume that the VM is halted / unresponsive and we
|
||||||
|
# carry on if it times out.
|
||||||
|
# [1] - https://github.com/mitchellh/vagrant/blob/57e95323b6600b146167f0f14f83b22dd31dd03f/plugins/communicators/ssh/communicator.rb#L185-L200
|
||||||
|
begin
|
||||||
|
Timeout.timeout(35) do
|
||||||
|
while true
|
||||||
|
return true if @machine.communicate.ready?
|
||||||
|
sleep 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue Timeout::Error
|
||||||
|
@env[:ui].warn(I18n.t('vagrant_cachier.unable_to_ssh'))
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def symlinks
|
def symlinks
|
||||||
# TODO: Check if file exists instead of a blank rescue
|
# TODO: Check if file exists instead of a blank rescue
|
||||||
@symlinks ||= @env[:machine].data_dir.join('cache_dirs').read.split rescue []
|
@symlinks ||= @machine.data_dir.join('cache_dirs').read.split rescue []
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_symlink(symlink)
|
def remove_symlink(symlink)
|
||||||
if @env[:machine].communicate.test("test -L #{symlink}")
|
if @machine.communicate.test("test -L #{symlink}")
|
||||||
@logger.debug "Removing symlink for '#{symlink}'"
|
@logger.info "Removing symlink for '#{symlink}'"
|
||||||
@env[:machine].communicate.sudo("unlink #{symlink}")
|
@machine.communicate.sudo("unlink #{symlink}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
67
lib/vagrant-cachier/action/configure_bucket_root.rb
Normal file
67
lib/vagrant-cachier/action/configure_bucket_root.rb
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
require 'timeout'
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Action
|
||||||
|
class ConfigureBucketRoot
|
||||||
|
def initialize(app, env)
|
||||||
|
@app = app
|
||||||
|
@logger = Log4r::Logger.new("vagrant::cachier::action::clean")
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
@env = env
|
||||||
|
|
||||||
|
if !env[:cache_buckets_folder_configured] && env[:machine].config.cache.enabled?
|
||||||
|
setup_buckets_folder
|
||||||
|
env[:cache_buckets_folder_configured] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
@app.call env
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_buckets_folder
|
||||||
|
FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?
|
||||||
|
|
||||||
|
synced_folder_opts = {id: "vagrant-cache"}
|
||||||
|
synced_folder_opts.merge!(@env[:machine].config.cache.synced_folder_opts || {})
|
||||||
|
|
||||||
|
@env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', synced_folder_opts
|
||||||
|
@env[:cache_dirs] = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def cache_root
|
||||||
|
@cache_root ||= case @env[:machine].config.cache.scope.to_sym
|
||||||
|
when :box
|
||||||
|
@box_name = box_name
|
||||||
|
# Box is optional with docker provider
|
||||||
|
if @box_name.nil? && @env[:machine].provider_name.to_sym == :docker
|
||||||
|
@image_name = image_name
|
||||||
|
# Use the image name if it's set
|
||||||
|
if @image_name
|
||||||
|
bucket_name = @image_name.gsub(':', '-')
|
||||||
|
else
|
||||||
|
raise "Cachier plugin only supported with docker provider when image is used"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
bucket_name = @box_name
|
||||||
|
end
|
||||||
|
@env[:home_path].join('cache', bucket_name)
|
||||||
|
when :machine
|
||||||
|
@env[:machine].data_dir.parent.join('cache')
|
||||||
|
else
|
||||||
|
raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def box_name
|
||||||
|
@env[:machine].config.vm.box
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_name
|
||||||
|
@env[:machine].provider_config.image
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,64 +0,0 @@
|
||||||
require_relative '../errors'
|
|
||||||
|
|
||||||
module VagrantPlugins
|
|
||||||
module Cachier
|
|
||||||
class Action
|
|
||||||
class EnsureSingleCacheRoot
|
|
||||||
def initialize(app, env)
|
|
||||||
@app = app
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
|
||||||
@env = env
|
|
||||||
|
|
||||||
# If the cache is scoped to boxes or the existing cache dirs are not
|
|
||||||
# provider specific, there's nothing we need to do
|
|
||||||
if cache_scoped_to_machine? && provider_specific_cache_dirs.any?
|
|
||||||
ensure_single_cache_root_exists!
|
|
||||||
end
|
|
||||||
|
|
||||||
@app.call(env)
|
|
||||||
end
|
|
||||||
|
|
||||||
def cache_scoped_to_machine?
|
|
||||||
@env[:machine].config.cache.enabled? &&
|
|
||||||
@env[:machine].config.cache.scope.to_sym == :machine
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_single_cache_root_exists!
|
|
||||||
if provider_specific_cache_dirs.size > 1
|
|
||||||
cache_dirs = provider_specific_cache_dirs.map do |dir|
|
|
||||||
" - #{dir.to_s.gsub(/^#{@env[:root_path]}\//, '')}"
|
|
||||||
end
|
|
||||||
machine_path = @env[:machine].data_dir.parent.to_s.gsub(/^#{@env[:root_path]}\//, '')
|
|
||||||
raise Cachier::Errors::MultipleProviderSpecificCacheDirsFound,
|
|
||||||
machine: @env[:machine].name,
|
|
||||||
machine_path: machine_path,
|
|
||||||
dirs: cache_dirs.join("\n")
|
|
||||||
else
|
|
||||||
current_path = provider_specific_cache_dirs.first.to_s.gsub(/^#{@env[:root_path]}\//, '')
|
|
||||||
new_path = @env[:machine].data_dir.parent.join('cache')
|
|
||||||
FileUtils.rm_rf new_path.to_s if new_path.directory?
|
|
||||||
|
|
||||||
new_path = new_path.to_s.gsub(/^#{@env[:root_path]}\//, '')
|
|
||||||
# If we got here there is a single provider specific cacher dir, so
|
|
||||||
# let's be nice with users and just fix it ;)
|
|
||||||
@env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir',
|
|
||||||
current_path: current_path,
|
|
||||||
new_path: new_path)
|
|
||||||
FileUtils.mv current_path, new_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def provider_specific_cache_dirs
|
|
||||||
return @provider_specific_cache_dirs if @provider_specific_cache_dirs
|
|
||||||
|
|
||||||
# By default data_dir points to ./.vagrant/machines/<NAME>/<PROVIDER>,
|
|
||||||
# so we go one directory up
|
|
||||||
machine_dir = @env[:machine].data_dir.parent
|
|
||||||
@provider_specific_cache_dirs = Pathname.glob(machine_dir.join('*/cache'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
66
lib/vagrant-cachier/action/install_buckets.rb
Normal file
66
lib/vagrant-cachier/action/install_buckets.rb
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
require_relative '../bucket'
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Action
|
||||||
|
class InstallBuckets
|
||||||
|
def initialize(app, env, opts = {})
|
||||||
|
@app = app
|
||||||
|
@logger = Log4r::Logger.new("vagrant::cachier::action::clean")
|
||||||
|
@opts = opts
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
@app.call(env)
|
||||||
|
|
||||||
|
return unless env[:machine].config.cache.enabled?
|
||||||
|
|
||||||
|
chmod_bucket_root(env[:machine]) if @opts[:chmod]
|
||||||
|
configure_cache_buckets(env)
|
||||||
|
end
|
||||||
|
|
||||||
|
def chmod_bucket_root(machine)
|
||||||
|
machine.communicate.sudo 'mkdir -p /tmp/vagrant-cache'
|
||||||
|
|
||||||
|
# https://github.com/fgrehm/vagrant-cachier/issues/107
|
||||||
|
if ! smb_synced_folder_enabled?(machine)
|
||||||
|
@logger.info "'chmod'ing bucket root dir to 777..."
|
||||||
|
machine.communicate.sudo 'chmod 777 /tmp/vagrant-cache'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def configure_cache_buckets(env)
|
||||||
|
if env[:machine].config.cache.auto_detect
|
||||||
|
Bucket.auto_detect(env)
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless env[:machine].config.cache.buckets.any?
|
||||||
|
|
||||||
|
env[:ui].info 'Configuring cache buckets...'
|
||||||
|
cache_config = env[:machine].config.cache
|
||||||
|
cache_config.buckets.each do |bucket_name, configs|
|
||||||
|
@logger.info "Installing #{bucket_name} with configs #{configs.inspect}"
|
||||||
|
Bucket.install(bucket_name, env, configs)
|
||||||
|
end
|
||||||
|
|
||||||
|
data_file = env[:machine].data_dir.join('cache_dirs')
|
||||||
|
data_file.open('w') { |f| f.print env[:cache_dirs].uniq.join("\n") }
|
||||||
|
end
|
||||||
|
|
||||||
|
def smb_synced_folder_enabled?(machine)
|
||||||
|
synced_folder_opts = machine.config.cache.synced_folder_opts
|
||||||
|
synced_folder_opts ||= {}
|
||||||
|
|
||||||
|
# If smb was explicitly enabled
|
||||||
|
if synced_folder_opts[:type] && synced_folder_opts[:type].to_s == 'smb'
|
||||||
|
return true
|
||||||
|
elsif machine.provider_name.to_sym == :hyperv
|
||||||
|
# If the provider in use is hyperv, the default synced folder is 'smb'
|
||||||
|
# unless specified
|
||||||
|
return synced_folder_opts[:type] == nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,19 +8,19 @@ module VagrantPlugins
|
||||||
|
|
||||||
def self.auto_detect(env)
|
def self.auto_detect(env)
|
||||||
@buckets.each do |bucket|
|
@buckets.each do |bucket|
|
||||||
if env[:machine].guest.capability?(bucket.capability)
|
if bucket.respond_to?(:capability) && env[:machine].guest.capability?(bucket.capability)
|
||||||
env[:machine].config.cache.enable bucket.bucket_name
|
env[:machine].config.cache.enable bucket.bucket_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.bucket_name
|
def self.bucket_name
|
||||||
# TODO: Handle MultiWord bucket classes
|
class_name = self.name.split('::').last
|
||||||
self.name.split('::').last.downcase
|
class_name.scan(/[A-Z][a-z]*/).map{|x| x.downcase}.join("_")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, env, configs)
|
def self.install(name, env, configs)
|
||||||
bucket = const_get(name.to_s.capitalize)
|
bucket = const_get(name.to_s.split("_").map{|x| x.capitalize}.join(""))
|
||||||
bucket.new(name, env, configs).install
|
bucket.new(name, env, configs).install
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,6 +29,60 @@ module VagrantPlugins
|
||||||
@env = env
|
@env = env
|
||||||
@configs = configs
|
@configs = configs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def machine
|
||||||
|
@env[:machine]
|
||||||
|
end
|
||||||
|
|
||||||
|
def guest
|
||||||
|
machine.guest
|
||||||
|
end
|
||||||
|
|
||||||
|
def comm
|
||||||
|
machine.communicate
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: "merge" symlink and user_symlink methods
|
||||||
|
def symlink(guest_path, bucket_path = "/tmp/vagrant-cache/#{@name}")
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
|
@env[:cache_dirs] << guest_path
|
||||||
|
comm.execute("mkdir -p #{bucket_path}")
|
||||||
|
unless symlink?(guest_path)
|
||||||
|
comm.sudo("mkdir -p `dirname #{guest_path}`")
|
||||||
|
if empty_dir?(bucket_path) && !empty_dir?(guest_path)
|
||||||
|
# Warm up cache with guest machine data
|
||||||
|
comm.sudo("shopt -s dotglob && mv #{guest_path}/* #{bucket_path}")
|
||||||
|
end
|
||||||
|
comm.sudo("rm -rf #{guest_path}")
|
||||||
|
comm.sudo("ln -s #{bucket_path} #{guest_path}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_symlink(guest_path)
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
|
@env[:cache_dirs] << guest_path
|
||||||
|
bucket_path = "/tmp/vagrant-cache/#{@name}"
|
||||||
|
comm.execute("mkdir -p #{bucket_path}")
|
||||||
|
unless symlink?(guest_path)
|
||||||
|
comm.execute("mkdir -p `dirname #{guest_path}`")
|
||||||
|
if empty_dir?(bucket_path) && !empty_dir?(guest_path)
|
||||||
|
# Warm up cache with guest machine data
|
||||||
|
comm.execute("shopt -s dotglob && mv #{guest_path}/* #{bucket_path}")
|
||||||
|
end
|
||||||
|
comm.execute("rm -rf #{guest_path}")
|
||||||
|
comm.execute("ln -s #{bucket_path} #{guest_path}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def empty_dir?(path)
|
||||||
|
not comm.test("test \"$(ls -A #{path} 2>/dev/null)\"")
|
||||||
|
end
|
||||||
|
|
||||||
|
def symlink?(path)
|
||||||
|
comm.test("test -L #{path}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,6 +90,16 @@ end
|
||||||
require_relative "bucket/apt"
|
require_relative "bucket/apt"
|
||||||
require_relative "bucket/chef"
|
require_relative "bucket/chef"
|
||||||
require_relative "bucket/gem"
|
require_relative "bucket/gem"
|
||||||
|
require_relative "bucket/chef_gem"
|
||||||
require_relative "bucket/pacman"
|
require_relative "bucket/pacman"
|
||||||
require_relative "bucket/yum"
|
require_relative "bucket/yum"
|
||||||
|
require_relative "bucket/dnf"
|
||||||
require_relative "bucket/rvm"
|
require_relative "bucket/rvm"
|
||||||
|
require_relative "bucket/apt_cacher"
|
||||||
|
require_relative "bucket/apt_lists"
|
||||||
|
require_relative "bucket/composer"
|
||||||
|
require_relative "bucket/bower"
|
||||||
|
require_relative "bucket/npm"
|
||||||
|
require_relative "bucket/zypper"
|
||||||
|
require_relative "bucket/generic"
|
||||||
|
require_relative "bucket/pip"
|
||||||
|
|
|
@ -7,22 +7,13 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:apt_cache_dir)
|
if guest.capability?(:apt_cache_dir)
|
||||||
guest_path = guest.capability(:apt_cache_dir)
|
guest_path = guest.capability(:apt_cache_dir)
|
||||||
|
|
||||||
@env[:cache_dirs] << guest_path
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
symlink(guest_path)
|
||||||
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
|
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}/partial")
|
||||||
unless comm.test("test -L #{guest_path}")
|
|
||||||
comm.sudo("rm -rf #{guest_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{guest_path}`")
|
|
||||||
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'APT')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'APT')
|
||||||
end
|
end
|
||||||
|
|
28
lib/vagrant-cachier/bucket/apt_cacher.rb
Normal file
28
lib/vagrant-cachier/bucket/apt_cacher.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Apt-Cacher NG is a caching proxy for software packages which are downloaded by
|
||||||
|
# Unix/Linux system distribution mechanisms from mirror servers accessible via HTTP.
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class AptCacher < Bucket
|
||||||
|
def self.capability
|
||||||
|
:apt_cacher_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:apt_cacher_dir)
|
||||||
|
if guest_path = guest.capability(:apt_cacher_dir)
|
||||||
|
synced_folder_type = (machine.config.cache.synced_folder_opts || {})[:type]
|
||||||
|
if synced_folder_type && synced_folder_type.to_sym == :nfs
|
||||||
|
symlink(guest_path)
|
||||||
|
else
|
||||||
|
@env[:ui].warn I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-cacher')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
28
lib/vagrant-cachier/bucket/apt_lists.rb
Normal file
28
lib/vagrant-cachier/bucket/apt_lists.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class AptLists < Bucket
|
||||||
|
def self.capability
|
||||||
|
:apt_lists_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
# Apt lists bucket can't be used on windows hosts
|
||||||
|
# https://github.com/fgrehm/vagrant-cachier/issues/106
|
||||||
|
return if Vagrant::Util::Platform.windows?
|
||||||
|
|
||||||
|
if guest.capability?(:apt_lists_dir)
|
||||||
|
guest_path = guest.capability(:apt_lists_dir)
|
||||||
|
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
|
symlink(guest_path)
|
||||||
|
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}/partial")
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-lists')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
21
lib/vagrant-cachier/bucket/bower.rb
Normal file
21
lib/vagrant-cachier/bucket/bower.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Bower < Bucket
|
||||||
|
def self.capability
|
||||||
|
:bower_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:bower_path)
|
||||||
|
if bower_path = guest.capability(:bower_path)
|
||||||
|
user_symlink(bower_path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Bower')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,22 +7,9 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:chef_file_cache_path)
|
if guest.capability?(:chef_file_cache_path)
|
||||||
guest_path = guest.capability(:chef_file_cache_path)
|
guest_path = guest.capability(:chef_file_cache_path)
|
||||||
|
symlink(guest_path) if guest_path
|
||||||
@env[:cache_dirs] << guest_path
|
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
|
||||||
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
|
|
||||||
unless comm.test("test -L #{guest_path}")
|
|
||||||
comm.sudo("rm -rf #{guest_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{guest_path}`")
|
|
||||||
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef')
|
||||||
end
|
end
|
||||||
|
|
25
lib/vagrant-cachier/bucket/chef_gem.rb
Normal file
25
lib/vagrant-cachier/bucket/chef_gem.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class ChefGem < Bucket
|
||||||
|
def self.capability
|
||||||
|
:chef_gemdir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:chef_gemdir)
|
||||||
|
if gemdir_path = guest.capability(:chef_gemdir)
|
||||||
|
prefix = gemdir_path.split('/').last
|
||||||
|
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
||||||
|
gem_cache_path = "#{gemdir_path}/cache"
|
||||||
|
|
||||||
|
symlink(gem_cache_path, bucket_path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'ChefRubyGems')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
21
lib/vagrant-cachier/bucket/composer.rb
Normal file
21
lib/vagrant-cachier/bucket/composer.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Composer < Bucket
|
||||||
|
def self.capability
|
||||||
|
:composer_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:composer_path)
|
||||||
|
if composer_path = guest.capability(:composer_path)
|
||||||
|
user_symlink(composer_path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
27
lib/vagrant-cachier/bucket/dnf.rb
Normal file
27
lib/vagrant-cachier/bucket/dnf.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Dnf < Bucket
|
||||||
|
def self.capability
|
||||||
|
:dnf_cache_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:dnf_cache_dir)
|
||||||
|
if guest_path = guest.capability(:dnf_cache_dir)
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
|
# Ensure caching is enabled
|
||||||
|
comm.sudo("sed -i '/keepcache=/d' /etc/dnf/dnf.conf")
|
||||||
|
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
|
||||||
|
|
||||||
|
symlink(guest_path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'DNF')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,26 +7,13 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:gemdir)
|
if guest.capability?(:gemdir)
|
||||||
if gemdir_path = guest.capability(:gemdir)
|
if gemdir_path = guest.capability(:gemdir)
|
||||||
prefix = gemdir_path.split('/').last
|
prefix = gemdir_path.split('/').last
|
||||||
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
||||||
machine.communicate.tap do |comm|
|
gem_cache_path = "#{gemdir_path}/cache"
|
||||||
comm.execute("mkdir -p #{bucket_path}")
|
|
||||||
|
|
||||||
gem_cache_path = "#{gemdir_path}/cache"
|
symlink(gem_cache_path, bucket_path)
|
||||||
|
|
||||||
@env[:cache_dirs] << gem_cache_path
|
|
||||||
|
|
||||||
unless comm.test("test -L #{gem_cache_path}")
|
|
||||||
comm.sudo("rm -rf #{gem_cache_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{gem_cache_path}`")
|
|
||||||
comm.sudo("ln -s #{bucket_path} #{gem_cache_path}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems')
|
||||||
|
|
26
lib/vagrant-cachier/bucket/generic.rb
Normal file
26
lib/vagrant-cachier/bucket/generic.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Generic < Bucket
|
||||||
|
def install
|
||||||
|
|
||||||
|
# First we normalize the @configs hash as a hash of hashes
|
||||||
|
if @configs.has_key?(:cache_dir)
|
||||||
|
@configs = { @name => @configs }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Now we iterate through all generic buckets's configurations and
|
||||||
|
# set them up.
|
||||||
|
@configs.each do |key, conf|
|
||||||
|
if conf.has_key?(:cache_dir)
|
||||||
|
symlink(conf[:cache_dir], "/tmp/vagrant-cache/#{key}")
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: "Generic[#{key}]")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
lib/vagrant-cachier/bucket/npm.rb
Normal file
20
lib/vagrant-cachier/bucket/npm.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Npm < Bucket
|
||||||
|
def self.capability
|
||||||
|
:npm_cache_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:npm_cache_dir)
|
||||||
|
guest_path = guest.capability(:npm_cache_dir)
|
||||||
|
user_symlink(guest_path) if guest_path
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'npm')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,22 +7,9 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:pacman_cache_dir)
|
if guest.capability?(:pacman_cache_dir)
|
||||||
guest_path = guest.capability(:pacman_cache_dir)
|
guest_path = guest.capability(:pacman_cache_dir)
|
||||||
|
symlink(guest_path)
|
||||||
@env[:cache_dirs] << guest_path
|
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
|
||||||
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
|
|
||||||
unless comm.test("test -L #{guest_path}")
|
|
||||||
comm.sudo("rm -rf #{guest_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{guest_path}`")
|
|
||||||
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman')
|
||||||
end
|
end
|
||||||
|
|
22
lib/vagrant-cachier/bucket/pip.rb
Normal file
22
lib/vagrant-cachier/bucket/pip.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Pip < Bucket
|
||||||
|
def self.capability
|
||||||
|
:pip_cache_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:pip_cache_dir)
|
||||||
|
if guest_path = guest.capability(:pip_cache_dir)
|
||||||
|
symlink("#{guest_path}/http", "/tmp/vagrant-cache/#{@name}/http")
|
||||||
|
symlink("#{guest_path}/wheels", "/tmp/vagrant-cache/#{@name}/wheels")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'pip')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,26 +7,13 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:rvm_path)
|
if guest.capability?(:rvm_path)
|
||||||
if rvm_path = guest.capability(:rvm_path)
|
if rvm_path = guest.capability(:rvm_path)
|
||||||
prefix = rvm_path.split('/').last
|
prefix = rvm_path.split('/').last
|
||||||
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
||||||
machine.communicate.tap do |comm|
|
rvm_cache_path = "#{rvm_path}/archives"
|
||||||
comm.execute("mkdir -p #{bucket_path}")
|
|
||||||
|
|
||||||
rvm_cache_path = "#{rvm_path}/archives"
|
symlink(rvm_cache_path, bucket_path)
|
||||||
|
|
||||||
@env[:cache_dirs] << rvm_cache_path
|
|
||||||
|
|
||||||
unless comm.test("test -L #{rvm_cache_path}")
|
|
||||||
comm.sudo("rm -rf #{rvm_cache_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{rvm_cache_path}`")
|
|
||||||
comm.sudo("ln -s #{bucket_path} #{rvm_cache_path}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM')
|
||||||
|
|
|
@ -7,24 +7,14 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
machine = @env[:machine]
|
|
||||||
guest = machine.guest
|
|
||||||
|
|
||||||
if guest.capability?(:yum_cache_dir)
|
if guest.capability?(:yum_cache_dir)
|
||||||
guest_path = guest.capability(:yum_cache_dir)
|
if guest_path = guest.capability(:yum_cache_dir)
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
@env[:cache_dirs] << guest_path
|
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
|
||||||
# Ensure caching is enabled
|
# Ensure caching is enabled
|
||||||
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
|
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
|
||||||
|
|
||||||
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
|
symlink(guest_path)
|
||||||
unless comm.test("test -L #{guest_path}")
|
|
||||||
comm.sudo("rm -rf #{guest_path}")
|
|
||||||
comm.sudo("mkdir -p `dirname #{guest_path}`")
|
|
||||||
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
|
||||||
|
|
25
lib/vagrant-cachier/bucket/zypper.rb
Normal file
25
lib/vagrant-cachier/bucket/zypper.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Bucket
|
||||||
|
class Zypper < Bucket
|
||||||
|
def self.capability
|
||||||
|
:zypper_cache_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
if guest.capability?(:zypper_cache_dir)
|
||||||
|
guest_path = guest.capability(:zypper_cache_dir)
|
||||||
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
|
# Ensure caching is enabled
|
||||||
|
comm.sudo("zypper modifyrepo --keep-packages --all")
|
||||||
|
|
||||||
|
symlink(guest_path)
|
||||||
|
else
|
||||||
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Zypper')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,7 +4,6 @@ module VagrantPlugins
|
||||||
module Arch
|
module Arch
|
||||||
module PacmanCacheDir
|
module PacmanCacheDir
|
||||||
def self.pacman_cache_dir(machine)
|
def self.pacman_cache_dir(machine)
|
||||||
# TODO: Find out if there is a config file we can read from
|
|
||||||
'/var/cache/pacman/pkg'
|
'/var/cache/pacman/pkg'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,6 @@ module VagrantPlugins
|
||||||
module Debian
|
module Debian
|
||||||
module AptCacheDir
|
module AptCacheDir
|
||||||
def self.apt_cache_dir(machine)
|
def self.apt_cache_dir(machine)
|
||||||
# TODO: Find out if there is a config file we can read from
|
|
||||||
'/var/cache/apt/archives'
|
'/var/cache/apt/archives'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
23
lib/vagrant-cachier/cap/debian/apt_cacher_dir.rb
Normal file
23
lib/vagrant-cachier/cap/debian/apt_cacher_dir.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Debian
|
||||||
|
module AptCacherDir
|
||||||
|
CACHER_CONF = '/etc/apt-cacher-ng/acng.conf'
|
||||||
|
CACHER_CACHE_DIR = "$(cat #{CACHER_CONF} | grep CacheDir | cut -d' ' -f 2)"
|
||||||
|
|
||||||
|
def self.apt_cacher_dir(machine)
|
||||||
|
cache_dir = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test("test -f #{CACHER_CONF}")
|
||||||
|
comm.execute "echo #{CACHER_CACHE_DIR}" do |buffer, output|
|
||||||
|
cache_dir = output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return cache_dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
13
lib/vagrant-cachier/cap/debian/apt_lists_dir.rb
Normal file
13
lib/vagrant-cachier/cap/debian/apt_lists_dir.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Debian
|
||||||
|
module AptListsDir
|
||||||
|
def self.apt_lists_dir(machine)
|
||||||
|
'/var/lib/apt/lists'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
lib/vagrant-cachier/cap/linux/bower_path.rb
Normal file
20
lib/vagrant-cachier/cap/linux/bower_path.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module BowerPath
|
||||||
|
def self.bower_path(machine)
|
||||||
|
bower_path = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('which bower')
|
||||||
|
comm.execute 'echo $HOME' do |buffer, output|
|
||||||
|
bower_path = output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "#{bower_path}/.cache/bower"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,8 +5,8 @@ module VagrantPlugins
|
||||||
module ChefFileCachePath
|
module ChefFileCachePath
|
||||||
def self.chef_provisioner?(machine)
|
def self.chef_provisioner?(machine)
|
||||||
provisioners = machine.config.vm.provisioners
|
provisioners = machine.config.vm.provisioners
|
||||||
chef_provisioners = [:chef_solo, :chef_client]
|
chef_provisioners = [:chef_solo, :chef_client, :chef_zero]
|
||||||
compat_provisioners = provisioners.keep_if { |p| chef_provisioners.include? p.name }
|
compat_provisioners = provisioners.select { |p| chef_provisioners.include? p.name || p.type }
|
||||||
|
|
||||||
if compat_provisioners.size > 1
|
if compat_provisioners.size > 1
|
||||||
raise "One machine is using multiple chef provisioners, which is unsupported."
|
raise "One machine is using multiple chef provisioners, which is unsupported."
|
||||||
|
@ -19,7 +19,6 @@ module VagrantPlugins
|
||||||
|
|
||||||
def self.chef_file_cache_path(machine)
|
def self.chef_file_cache_path(machine)
|
||||||
chef_file_cache_path = nil
|
chef_file_cache_path = nil
|
||||||
# TODO: Determine paths rather than using default.
|
|
||||||
chef_file_cache_path = '/var/chef/cache' if chef_provisioner?(machine)
|
chef_file_cache_path = '/var/chef/cache' if chef_provisioner?(machine)
|
||||||
|
|
||||||
return chef_file_cache_path
|
return chef_file_cache_path
|
||||||
|
|
20
lib/vagrant-cachier/cap/linux/chef_gemdir.rb
Normal file
20
lib/vagrant-cachier/cap/linux/chef_gemdir.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module ChefGemdir
|
||||||
|
def self.chef_gemdir(machine)
|
||||||
|
gemdir = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('test -f /opt/chef/embedded/bin/gem')
|
||||||
|
comm.execute '/opt/chef/embedded/bin/gem env gemdir' do |buffer, output|
|
||||||
|
gemdir = output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return gemdir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
23
lib/vagrant-cachier/cap/linux/composer_path.rb
Normal file
23
lib/vagrant-cachier/cap/linux/composer_path.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module ComposerPath
|
||||||
|
def self.composer_path(machine)
|
||||||
|
composer_path = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('which php')
|
||||||
|
# on some VMs an extra new line seems to come out, so we loop over
|
||||||
|
# the output just in case
|
||||||
|
composer_path = ''
|
||||||
|
comm.execute 'echo $HOME' do |buffer, output|
|
||||||
|
composer_path += output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "#{composer_path}/.composer/cache"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
lib/vagrant-cachier/cap/linux/npm_cache_dir.rb
Normal file
20
lib/vagrant-cachier/cap/linux/npm_cache_dir.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module NpmCacheDir
|
||||||
|
def self.npm_cache_dir(machine)
|
||||||
|
npm_cache_dir = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('which npm')
|
||||||
|
comm.execute 'npm config get cache' do |buffer, output|
|
||||||
|
npm_cache_dir = output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return npm_cache_dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
lib/vagrant-cachier/cap/linux/pip_cache_dir.rb
Normal file
20
lib/vagrant-cachier/cap/linux/pip_cache_dir.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module PipCacheDir
|
||||||
|
def self.pip_cache_dir(machine)
|
||||||
|
pip_cache_dir = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('which pip')
|
||||||
|
comm.execute 'echo $HOME' do |buffer, output|
|
||||||
|
pip_cache_dir = output.chomp if buffer == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "#{pip_cache_dir}/.cache/pip"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
18
lib/vagrant-cachier/cap/redhat/dnf_cache_dir.rb
Normal file
18
lib/vagrant-cachier/cap/redhat/dnf_cache_dir.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module RedHat
|
||||||
|
module DnfCacheDir
|
||||||
|
def self.dnf_cache_dir(machine)
|
||||||
|
dnf_cache_dir = nil
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
return unless comm.test('which dnf')
|
||||||
|
dnf_cache_dir = '/var/cache/dnf'
|
||||||
|
end
|
||||||
|
return dnf_cache_dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,8 +4,13 @@ module VagrantPlugins
|
||||||
module RedHat
|
module RedHat
|
||||||
module YumCacheDir
|
module YumCacheDir
|
||||||
def self.yum_cache_dir(machine)
|
def self.yum_cache_dir(machine)
|
||||||
# TODO: Find out if there is a config file we can read from
|
yum_cache_dir = nil
|
||||||
'/var/cache/yum'
|
machine.communicate.tap do |comm|
|
||||||
|
# In case yum is only forwarding to dnf do not cache
|
||||||
|
return unless not comm.test('yum --version 2>&1 | grep /usr/bin/dnf')
|
||||||
|
yum_cache_dir = '/var/cache/yum'
|
||||||
|
end
|
||||||
|
return yum_cache_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
13
lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb
Normal file
13
lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
module Cap
|
||||||
|
module SuSE
|
||||||
|
module ZypperCacheDir
|
||||||
|
def self.zypper_cache_dir(machine)
|
||||||
|
'/var/cache/zypp/packages'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
84
lib/vagrant-cachier/capabilities.rb
Normal file
84
lib/vagrant-cachier/capabilities.rb
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Plugin < Vagrant.plugin('2')
|
||||||
|
guest_capability 'linux', 'gemdir' do
|
||||||
|
require_relative 'cap/linux/gemdir'
|
||||||
|
Cap::Linux::Gemdir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'chef_gemdir' do
|
||||||
|
require_relative 'cap/linux/chef_gemdir'
|
||||||
|
Cap::Linux::ChefGemdir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'rvm_path' do
|
||||||
|
require_relative 'cap/linux/rvm_path'
|
||||||
|
Cap::Linux::RvmPath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'composer_path' do
|
||||||
|
require_relative 'cap/linux/composer_path'
|
||||||
|
Cap::Linux::ComposerPath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'bower_path' do
|
||||||
|
require_relative 'cap/linux/bower_path'
|
||||||
|
Cap::Linux::BowerPath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'chef_file_cache_path' do
|
||||||
|
require_relative 'cap/linux/chef_file_cache_path'
|
||||||
|
Cap::Linux::ChefFileCachePath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'npm_cache_dir' do
|
||||||
|
require_relative 'cap/linux/npm_cache_dir'
|
||||||
|
Cap::Linux::NpmCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'pip_cache_dir' do
|
||||||
|
require_relative 'cap/linux/pip_cache_dir'
|
||||||
|
Cap::Linux::PipCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'debian', 'apt_cache_dir' do
|
||||||
|
require_relative 'cap/debian/apt_cache_dir'
|
||||||
|
Cap::Debian::AptCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'debian', 'apt_cacher_dir' do
|
||||||
|
require_relative 'cap/debian/apt_cacher_dir'
|
||||||
|
Cap::Debian::AptCacherDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'debian', 'apt_lists_dir' do
|
||||||
|
require_relative 'cap/debian/apt_lists_dir'
|
||||||
|
Cap::Debian::AptListsDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'redhat', 'yum_cache_dir' do
|
||||||
|
require_relative 'cap/redhat/yum_cache_dir'
|
||||||
|
Cap::RedHat::YumCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'redhat', 'dnf_cache_dir' do
|
||||||
|
require_relative 'cap/redhat/dnf_cache_dir'
|
||||||
|
Cap::RedHat::DnfCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'suse', 'yum_cache_dir' do
|
||||||
|
# Disable Yum on suse guests
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'arch', 'pacman_cache_dir' do
|
||||||
|
require_relative 'cap/arch/pacman_cache_dir'
|
||||||
|
Cap::Arch::PacmanCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'suse', 'zypper_cache_dir' do
|
||||||
|
require_relative 'cap/suse/zypper_cache_dir'
|
||||||
|
Cap::SuSE::ZypperCacheDir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,15 +1,16 @@
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Cachier
|
module Cachier
|
||||||
class Config < Vagrant.plugin(2, :config)
|
class Config < Vagrant.plugin(2, :config)
|
||||||
attr_accessor :scope, :auto_detect, :enable_nfs
|
attr_accessor :scope, :auto_detect, :synced_folder_opts
|
||||||
attr_reader :buckets
|
attr_reader :buckets
|
||||||
|
|
||||||
ALLOWED_SCOPES = %w( box machine )
|
ALLOWED_SCOPES = %w( box machine )
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@scope = UNSET_VALUE
|
@scope = UNSET_VALUE
|
||||||
@auto_detect = UNSET_VALUE
|
@auto_detect = UNSET_VALUE
|
||||||
@enable_nfs = UNSET_VALUE
|
@synced_folder_opts = UNSET_VALUE
|
||||||
|
@ui = Vagrant::UI::Colored.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable(bucket, opts = {})
|
def enable(bucket, opts = {})
|
||||||
|
@ -19,6 +20,12 @@ module VagrantPlugins
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
errors = _detected_errors
|
errors = _detected_errors
|
||||||
|
|
||||||
|
if enabled? && backed_by_cloud_provider?(machine)
|
||||||
|
machine.ui.warn(I18n.t('vagrant_cachier.backed_by_cloud_provider',
|
||||||
|
provider: machine.provider_name))
|
||||||
|
disable!
|
||||||
|
end
|
||||||
|
|
||||||
if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s)
|
if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s)
|
||||||
errors << I18n.t('vagrant_cachier.unknown_cache_scope',
|
errors << I18n.t('vagrant_cachier.unknown_cache_scope',
|
||||||
allowed: ALLOWED_SCOPES.inspect,
|
allowed: ALLOWED_SCOPES.inspect,
|
||||||
|
@ -28,18 +35,28 @@ module VagrantPlugins
|
||||||
{ "vagrant cachier" => errors }
|
{ "vagrant cachier" => errors }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enabled?
|
||||||
|
return @enabled unless @enabled.nil?
|
||||||
|
|
||||||
|
@enabled = @scope != UNSET_VALUE
|
||||||
|
end
|
||||||
|
|
||||||
|
def disable!
|
||||||
|
@enabled = false
|
||||||
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
return unless enabled?
|
return unless enabled?
|
||||||
|
|
||||||
@scope = :box if @scope == UNSET_VALUE
|
@auto_detect = true if @auto_detect == UNSET_VALUE
|
||||||
@auto_detect = false if @auto_detect == UNSET_VALUE
|
@synced_folder_opts = nil if @synced_folder_opts == UNSET_VALUE
|
||||||
@enable_nfs = false if @enable_nfs == UNSET_VALUE
|
@buckets = @buckets ? @buckets.dup : {}
|
||||||
@buckets = @buckets ? @buckets.dup : {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled?
|
private
|
||||||
@enabled ||= @auto_detect != UNSET_VALUE ||
|
|
||||||
@buckets != nil
|
def backed_by_cloud_provider?(machine)
|
||||||
|
CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module Cachier
|
|
||||||
module Errors
|
|
||||||
class MultipleProviderSpecificCacheDirsFound < Vagrant::Errors::VagrantError
|
|
||||||
error_key(:multiple_provider_specific_cache_dirs_found)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
27
lib/vagrant-cachier/hooks.rb
Normal file
27
lib/vagrant-cachier/hooks.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Plugin < Vagrant.plugin('2')
|
||||||
|
action_hook VagrantPlugins::Cachier::Plugin::ALL_ACTIONS do |hook|
|
||||||
|
require_relative 'action/configure_bucket_root'
|
||||||
|
require_relative 'action/install_buckets'
|
||||||
|
|
||||||
|
hook.before Vagrant::Action::Builtin::Provision, Action::ConfigureBucketRoot
|
||||||
|
# This will do the initial buckets installation
|
||||||
|
hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets, chmod: true
|
||||||
|
end
|
||||||
|
|
||||||
|
# This ensure buckets are reconfigured after provisioners runs
|
||||||
|
action_hook :provisioner_run do |hook|
|
||||||
|
require_relative 'action/install_buckets'
|
||||||
|
hook.after :run_provisioner, Action::InstallBuckets
|
||||||
|
end
|
||||||
|
|
||||||
|
clean_action_hook = lambda do |hook|
|
||||||
|
require_relative 'action/clean'
|
||||||
|
hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
|
||||||
|
end
|
||||||
|
action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook
|
||||||
|
action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,5 @@
|
||||||
require_relative 'provision_ext'
|
unless Gem::Requirement.new('>= 1.4.0').satisfied_by?(Gem::Version.new(Vagrant::VERSION))
|
||||||
Vagrant::Action::Builtin::Provision.class_eval do
|
raise 'vagrant-cachier requires Vagrant >= 1.4.0 in order to work!'
|
||||||
include VagrantPlugins::Cachier::ProvisionExt
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add our custom translations to the load path
|
# Add our custom translations to the load path
|
||||||
|
@ -10,63 +9,19 @@ module VagrantPlugins
|
||||||
module Cachier
|
module Cachier
|
||||||
class Plugin < Vagrant.plugin('2')
|
class Plugin < Vagrant.plugin('2')
|
||||||
name 'vagrant-cachier'
|
name 'vagrant-cachier'
|
||||||
|
|
||||||
config 'cache' do
|
config 'cache' do
|
||||||
require_relative "config"
|
require_relative "config"
|
||||||
Config
|
Config
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability 'linux', 'gemdir' do
|
|
||||||
require_relative 'cap/linux/gemdir'
|
|
||||||
Cap::Linux::Gemdir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'linux', 'rvm_path' do
|
|
||||||
require_relative 'cap/linux/rvm_path'
|
|
||||||
Cap::Linux::RvmPath
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'linux', 'chef_file_cache_path' do
|
|
||||||
require_relative 'cap/linux/chef_file_cache_path'
|
|
||||||
Cap::Linux::ChefFileCachePath
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'debian', 'apt_cache_dir' do
|
|
||||||
require_relative 'cap/debian/apt_cache_dir'
|
|
||||||
Cap::Debian::AptCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'redhat', 'yum_cache_dir' do
|
|
||||||
require_relative 'cap/redhat/yum_cache_dir'
|
|
||||||
Cap::RedHat::YumCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'arch', 'pacman_cache_dir' do
|
|
||||||
require_relative 'cap/arch/pacman_cache_dir'
|
|
||||||
Cap::Arch::PacmanCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: This should be generic, we don't want to hard code every single
|
|
||||||
# possible provider action class that Vagrant might have
|
|
||||||
ensure_single_cache_root = lambda do |hook|
|
|
||||||
require_relative 'action/ensure_single_cache_root'
|
|
||||||
hook.before VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot
|
|
||||||
|
|
||||||
if defined?(Vagrant::LXC)
|
|
||||||
# TODO: Require just the boot action file once its "require dependencies" are sorted out
|
|
||||||
require 'vagrant-lxc/action'
|
|
||||||
hook.before Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot
|
|
||||||
end
|
|
||||||
end
|
|
||||||
action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root
|
|
||||||
action_hook 'ensure-single-cache-root-exists-on-reload', :machine_action_reload, &ensure_single_cache_root
|
|
||||||
|
|
||||||
clean_action_hook = lambda do |hook|
|
|
||||||
require_relative 'action/clean'
|
|
||||||
hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
|
|
||||||
end
|
|
||||||
action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook
|
|
||||||
action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Keep an eye on https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins#wiki-providers
|
||||||
|
# for more.
|
||||||
|
CLOUD_PROVIDERS = %w( aws cloudstack digitalocean hp joyent openstack rackspace
|
||||||
|
softlayer proxmox managed azure brightbox cloudstack vcloud
|
||||||
|
vsphere )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require_relative "hooks"
|
||||||
|
require_relative "capabilities"
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
require_relative 'bucket'
|
|
||||||
|
|
||||||
module VagrantPlugins
|
|
||||||
module Cachier
|
|
||||||
module ProvisionExt
|
|
||||||
def self.included(base)
|
|
||||||
base.class_eval do
|
|
||||||
def cachier_debug(msg)
|
|
||||||
@logger.debug "[CACHIER] #{msg}"
|
|
||||||
end
|
|
||||||
|
|
||||||
alias :old_call :call
|
|
||||||
def call(env)
|
|
||||||
return old_call(env) unless env[:machine].config.cache.enabled?
|
|
||||||
|
|
||||||
@env = env
|
|
||||||
|
|
||||||
FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?
|
|
||||||
|
|
||||||
nfs_flag = env[:machine].config.cache.enable_nfs
|
|
||||||
env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag
|
|
||||||
|
|
||||||
env[:cache_dirs] = []
|
|
||||||
|
|
||||||
old_call(env)
|
|
||||||
|
|
||||||
configure_cache_buckets
|
|
||||||
end
|
|
||||||
|
|
||||||
alias :old_run_provisioner :run_provisioner
|
|
||||||
def run_provisioner(*args)
|
|
||||||
configure_cache_buckets
|
|
||||||
old_run_provisioner(*args)
|
|
||||||
end
|
|
||||||
|
|
||||||
def configure_cache_buckets
|
|
||||||
return unless @env[:machine].config.cache.enabled?
|
|
||||||
|
|
||||||
if @env[:machine].config.cache.auto_detect
|
|
||||||
Bucket.auto_detect(@env)
|
|
||||||
end
|
|
||||||
|
|
||||||
return unless @env[:machine].config.cache.buckets.any?
|
|
||||||
|
|
||||||
@env[:ui].info 'Configuring cache buckets...'
|
|
||||||
cache_config = @env[:machine].config.cache
|
|
||||||
cache_config.buckets.each do |bucket_name, configs|
|
|
||||||
cachier_debug "Installing #{bucket_name} with configs #{configs.inspect}"
|
|
||||||
Bucket.install(bucket_name, @env, configs)
|
|
||||||
end
|
|
||||||
|
|
||||||
data_file = @env[:machine].data_dir.join('cache_dirs')
|
|
||||||
data_file.open('w') { |f| f.print @env[:cache_dirs].uniq.join("\n") }
|
|
||||||
end
|
|
||||||
|
|
||||||
def cache_root
|
|
||||||
@cache_root ||= case @env[:machine].config.cache.scope.to_sym
|
|
||||||
when :box
|
|
||||||
@env[:home_path].join('cache', @env[:machine].box.name)
|
|
||||||
when :machine
|
|
||||||
@env[:machine].data_dir.parent.join('cache')
|
|
||||||
else
|
|
||||||
raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,5 @@
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Cachier
|
module Cachier
|
||||||
VERSION = "0.3.1"
|
VERSION = "1.2.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,15 +6,11 @@ en:
|
||||||
Skipping %{bucket} cache bucket as the guest machine does not support it
|
Skipping %{bucket} cache bucket as the guest machine does not support it
|
||||||
unknown_cache_scope: |-
|
unknown_cache_scope: |-
|
||||||
Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed})
|
Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed})
|
||||||
will_fix_machine_cache_dir: |-
|
nfs_required: |-
|
||||||
A vagrant-cachier provider specific cache dir was found under
|
The '%{bucket}' cache bucket requires NFS to be enabled, please add
|
||||||
'%{current_path}' and it will be moved to
|
`config.cache.synced_folder_opts = {type: :nfs}` to your Vagrantfile.
|
||||||
'%{new_path}' as it is the new path for keeping machine
|
unable_to_ssh: |-
|
||||||
scoped cache dirs starting with the 0.3.0 version of the plugin.
|
vagrant-cachier was unable to SSH into the VM to remove symlinks!
|
||||||
vagrant:
|
backed_by_cloud_provider: |-
|
||||||
errors:
|
The machine is backed by a cloud provider (%{provider}), caching
|
||||||
multiple_provider_specific_cache_dirs_found: |-
|
will be disabled.
|
||||||
There are multiple provider specific cache dirs for the '%{machine}' machine:
|
|
||||||
%{dirs}
|
|
||||||
Please move one of them up to `%{machine_path}/cache` and remove the others
|
|
||||||
before bringing the machine up again.
|
|
||||||
|
|
14
spec/acceptance/fixtures/auto-detect-with-provisioning.rb
Normal file
14
spec/acceptance/fixtures/auto-detect-with-provisioning.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :virtualbox do |_, override|
|
||||||
|
override.vm.box = "chef/ubuntu-14.04"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.provider :lxc do |_, override|
|
||||||
|
override.vm.box = "fgrehm/trusty64-lxc"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.cache.auto_detect = true
|
||||||
|
config.cache.scope = :machine
|
||||||
|
|
||||||
|
config.vm.provision :shell, inline: 'apt-get update && apt-get install -y git'
|
||||||
|
end
|
12
spec/acceptance/fixtures/auto-detect.rb
Normal file
12
spec/acceptance/fixtures/auto-detect.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :virtualbox do |_, override|
|
||||||
|
override.vm.box = "chef/ubuntu-14.04"
|
||||||
|
end
|
||||||
|
config.vm.provider :lxc do |_, override|
|
||||||
|
override.vm.box = "fgrehm/trusty64-lxc"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.cache.auto_detect = true
|
||||||
|
|
||||||
|
config.vm.provision :shell, inline: 'echo Hello!'
|
||||||
|
end
|
8
spec/acceptance/fixtures/no-cachier-simple.rb
Normal file
8
spec/acceptance/fixtures/no-cachier-simple.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :virtualbox do |_, override|
|
||||||
|
override.vm.box = "chef/ubuntu-14.04"
|
||||||
|
end
|
||||||
|
config.vm.provider :lxc do |_, override|
|
||||||
|
override.vm.box = "fgrehm/trusty64-lxc"
|
||||||
|
end
|
||||||
|
end
|
10
spec/acceptance/fixtures/no-cachier-with-provisioning.rb
Normal file
10
spec/acceptance/fixtures/no-cachier-with-provisioning.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :virtualbox do |_, override|
|
||||||
|
override.vm.box = "chef/ubuntu-14.04"
|
||||||
|
end
|
||||||
|
config.vm.provider :lxc do |_, override|
|
||||||
|
override.vm.box = "fgrehm/trusty64-lxc"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.provision :shell, inline: 'echo Hello!'
|
||||||
|
end
|
45
spec/acceptance/sanity_check.bats
Normal file
45
spec/acceptance/sanity_check.bats
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
@test "Vagrantfile without cachier statement does not blow up when bringing the VM up" {
|
||||||
|
configure_env "no-cachier-simple.rb"
|
||||||
|
vagrant_up
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
vagrant_destroy
|
||||||
|
|
||||||
|
configure_env "no-cachier-with-provisioning.rb"
|
||||||
|
vagrant_up
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
vagrant_destroy
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Vagrantfile with cachier auto_detect statement does not blow up when bringing the VM up" {
|
||||||
|
configure_env "auto-detect.rb"
|
||||||
|
vagrant_up
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
vagrant_destroy
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "APT cache bucket configures the cache dir properly and keeps cache dir around" {
|
||||||
|
configure_env "auto-detect-with-provisioning.rb"
|
||||||
|
|
||||||
|
# Make sure cache dir does not exist
|
||||||
|
test ! -d tmp/.vagrant/machines/default/cache/apt
|
||||||
|
|
||||||
|
vagrant_up
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
# Make sure packages are being cached
|
||||||
|
test -d tmp/.vagrant/machines/default/cache/apt
|
||||||
|
FILES=(`ls tmp/.vagrant/machines/default/cache/apt/git*.deb`)
|
||||||
|
[ ${#FILES[@]} -gt 0 ]
|
||||||
|
|
||||||
|
vagrant_destroy
|
||||||
|
|
||||||
|
# Make sure packages are not removed between machine rebuilds
|
||||||
|
FILES=(`ls tmp/.vagrant/machines/default/cache/apt/git*.deb`)
|
||||||
|
[ ${#FILES[@]} -gt 0 ]
|
||||||
|
|
||||||
|
empty_cache
|
||||||
|
}
|
26
spec/acceptance/test_helper.bash
Normal file
26
spec/acceptance/test_helper.bash
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
vagrant_up() {
|
||||||
|
pushd tmp
|
||||||
|
run bundle exec vagrant up > /tmp/vagrant-cachier-tests.log
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
vagrant_destroy() {
|
||||||
|
pushd tmp
|
||||||
|
run bundle exec vagrant destroy -f
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_env() {
|
||||||
|
fixture=$1
|
||||||
|
|
||||||
|
mkdir -p tmp/
|
||||||
|
cp spec/acceptance/fixtures/${fixture} tmp/Vagrantfile
|
||||||
|
|
||||||
|
vagrant_destroy
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
rm -rf tmp/.vagrant
|
||||||
|
}
|
||||||
|
|
||||||
|
empty_cache() {
|
||||||
|
rm -rf tmp/.vagrant/cache
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.version = VagrantPlugins::Cachier::VERSION
|
spec.version = VagrantPlugins::Cachier::VERSION
|
||||||
spec.authors = ["Fabio Rehm"]
|
spec.authors = ["Fabio Rehm"]
|
||||||
spec.email = ["fgrehm@gmail.com"]
|
spec.email = ["fgrehm@gmail.com"]
|
||||||
spec.description = %q{Speed up vagrant boxes provisioning}
|
spec.description = %q{Caffeine reducer}
|
||||||
spec.summary = spec.description
|
spec.summary = spec.description
|
||||||
spec.homepage = "https://github.com/fgrehm/vagrant-cachier"
|
spec.homepage = "https://github.com/fgrehm/vagrant-cachier"
|
||||||
spec.license = "MIT"
|
spec.license = "MIT"
|
||||||
|
|
Loading…
Add table
Reference in a new issue