vagrant-berkshelf 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +18 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +35 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +13 -0
- data/README.md +35 -0
- data/Thorfile +58 -0
- data/lib/berkshelf/vagrant.rb +45 -0
- data/lib/berkshelf/vagrant/action.rb +63 -0
- data/lib/berkshelf/vagrant/action/clean.rb +28 -0
- data/lib/berkshelf/vagrant/action/configure_chef.rb +28 -0
- data/lib/berkshelf/vagrant/action/install.rb +71 -0
- data/lib/berkshelf/vagrant/action/load_shelf.rb +50 -0
- data/lib/berkshelf/vagrant/action/set_ui.rb +17 -0
- data/lib/berkshelf/vagrant/action/upload.rb +50 -0
- data/lib/berkshelf/vagrant/config.rb +91 -0
- data/lib/berkshelf/vagrant/env.rb +26 -0
- data/lib/berkshelf/vagrant/env_helpers.rb +64 -0
- data/lib/berkshelf/vagrant/errors.rb +33 -0
- data/lib/berkshelf/vagrant/plugin.rb +42 -0
- data/lib/berkshelf/vagrant/version.rb +5 -0
- data/lib/vagrant-berkshelf.rb +1 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/unit/berkshelf/vagrant/config_spec.rb +97 -0
- data/spec/unit/berkshelf/vagrant/errors_spec.rb +12 -0
- data/spec/unit/berkshelf/vagrant_spec.rb +25 -0
- data/vagrant-berkshelf.gemspec +36 -0
- metadata +230 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzE0MzU1NWI1YjNlNTFiNGEwYjFlNGI4YzM3YTcyYWEyZmYzZTc1Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjBhYTE3OTU0OTc2NzZiNzhkMjJlZjJjMGE4ZGRmNzNiMjhkZTM2OA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZjBlMzI2YTQzMDljZjhkOTNlMWU3YzY5ZWNlNzYyZTdjZTk3MDkxNzM0Njll
|
10
|
+
ODQzNzdmZjYyYjU2OGE2NjQ0ODgyZTA2NTljZTk1OTU5MzUwMDVjODkyYjc1
|
11
|
+
YjJlNjRkZDgyZjk0MDE3MGQ4ODY4ZmNkMzdiYzkwN2M1ZDBkMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTgxZmYwMGI3ZGM4NWNlYmE3OTkwMjc5OGZkYzZhN2Y0MmFhMmZmYTEzOWU2
|
14
|
+
YTlhOGUyNDEwODk4NDYzNjFlMGI5M2RiNjc4MjNlMmNhYTkzNjJlMmQwZDc1
|
15
|
+
ZmMzNWEzNGQxYWE3ZDJjYmMxNGVkZTQ4ZGZlMDdhNmM4MTJiODE=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# 1.2.0
|
2
|
+
- Rename to vagrant-berkshelf
|
3
|
+
- Trigger the plugin also on `vagrant reload`
|
4
|
+
- Check Vagrant version to see if it's supported
|
5
|
+
- cookbooks uploaded via chef_client will be forced and not frozen
|
6
|
+
- Fix bug with AWS provisioner
|
7
|
+
- Respect --no-provision flag
|
8
|
+
|
9
|
+
# 1.1.2
|
10
|
+
- Support Vagrant 1.2
|
11
|
+
- Plugin defaults to enabled, if Berksfile exists.
|
12
|
+
|
13
|
+
# 1.1.0
|
14
|
+
- Plugin defaults to disabled. Set 'config.berkshelf.enabled = true' in Vagrant config
|
15
|
+
|
16
|
+
# 1.0.0
|
17
|
+
- Separated Berkshelf Vagrant plugin into it's own gem (this one)
|
18
|
+
- Support Vagrant 1.1.x
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
## Developing
|
4
|
+
|
5
|
+
If you'd like to submit a patch:
|
6
|
+
|
7
|
+
1. Fork the project.
|
8
|
+
2. Make your feature addition or bug fix.
|
9
|
+
3. Add [tests](#testing) for it. This is important so that it isn't broken in a
|
10
|
+
future version unintentionally.
|
11
|
+
4. Commit. **Do not touch any unrelated code, such as the gemspec or version.**
|
12
|
+
If you must change unrelated code, do it in a commit by itself, so that it
|
13
|
+
can be ignored.
|
14
|
+
5. Send a pull request.
|
15
|
+
|
16
|
+
## Testing
|
17
|
+
|
18
|
+
### Install prerequisites
|
19
|
+
|
20
|
+
Install the latest version of [Bundler](http://gembundler.com)
|
21
|
+
|
22
|
+
$ gem install bundler
|
23
|
+
|
24
|
+
Clone the project
|
25
|
+
|
26
|
+
$ git clone git://github.com/RiotGames/vagrant-berkshelf.git
|
27
|
+
|
28
|
+
and run:
|
29
|
+
|
30
|
+
$ cd vagrant-berkshelf
|
31
|
+
$ bundle-vagrant install
|
32
|
+
|
33
|
+
Bundler will install all gems and their dependencies required for testing and developing.
|
34
|
+
|
35
|
+
### Running unit (RSpec) tests
|
36
|
+
|
37
|
+
One-time run with Thor
|
38
|
+
|
39
|
+
$ bundle exec thor spec
|
40
|
+
|
41
|
+
Or you can setup a quick feedback loop with Guard
|
42
|
+
|
43
|
+
$ bundle exec guard start
|
44
|
+
guard> rspec
|
data/Gemfile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'vagrant', github: "mitchellh/vagrant"
|
7
|
+
gem 'coolline'
|
8
|
+
gem 'guard', '>= 1.5.0'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
gem 'guard-spork'
|
11
|
+
gem 'guard-yard'
|
12
|
+
gem 'redcarpet'
|
13
|
+
gem 'yard'
|
14
|
+
gem 'fuubar'
|
15
|
+
|
16
|
+
require 'rbconfig'
|
17
|
+
|
18
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
19
|
+
gem 'growl', require: false
|
20
|
+
gem 'rb-fsevent', require: false
|
21
|
+
|
22
|
+
if `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
|
23
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
24
|
+
end rescue Errno::ENOENT
|
25
|
+
|
26
|
+
elsif RbConfig::CONFIG['target_os'] =~ /linux/i
|
27
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
28
|
+
gem 'rb-inotify', require: false
|
29
|
+
|
30
|
+
elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
31
|
+
gem 'rb-notifu', '>= 0.0.4', require: false
|
32
|
+
gem 'wdm', require: false
|
33
|
+
gem 'win32console', require: false
|
34
|
+
end
|
35
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
guard 'spork' do
|
2
|
+
watch('Gemfile')
|
3
|
+
watch('spec/spec_helper.rb') { :rspec }
|
4
|
+
end
|
5
|
+
|
6
|
+
guard 'yard', stdout: '/dev/null', stderr: '/dev/null' do
|
7
|
+
watch(%r{app/.+\.rb})
|
8
|
+
watch(%r{lib/.+\.rb})
|
9
|
+
watch(%r{ext/.+\.c})
|
10
|
+
end
|
11
|
+
|
12
|
+
guard 'rspec', cli: "--color --drb --format Fuubar", all_on_start: false, all_after_pass: false do
|
13
|
+
watch(%r{^spec/unit/.+_spec\.rb$})
|
14
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
|
15
|
+
watch('spec/spec_helper.rb') { "spec" }
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2013 Riot Games
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Berkshelf::Vagrant
|
2
|
+
[](http://badge.fury.io/rb/vagrant-berkshelf)
|
3
|
+
[](https://travis-ci.org/RiotGames/vagrant-berkshelf)
|
4
|
+
[](https://gemnasium.com/RiotGames/vagrant-berkshelf)
|
5
|
+
[](https://codeclimate.com/github/RiotGames/vagrant-berkshelf)
|
6
|
+
|
7
|
+
A Vagrant plugin to add Berkshelf integration to the Chef provisioners
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install Vagrant 1.1.x from the [Vagrant downloads page](http://downloads.vagrantup.com/)
|
12
|
+
|
13
|
+
Install the Berkshelf Vagrant plugin
|
14
|
+
|
15
|
+
$ vagrant plugin install vagrant-berkshelf
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Once the Berkshelf Vagrant plugin is installed it can be enabled in your Vagrantfile
|
20
|
+
|
21
|
+
|
22
|
+
Vagrant.configure("2") do |config|
|
23
|
+
...
|
24
|
+
config.berkshelf.enabled = true
|
25
|
+
...
|
26
|
+
end
|
27
|
+
|
28
|
+
The plugin will look in your current working directory for your `Berksfile` by default. Just ensure that your Berksfile exists and when you run `vagrant up`, `vagrant provision`, or `vagrant destroy` the Berkshelf integration will automatically kick in!
|
29
|
+
|
30
|
+
# Authors
|
31
|
+
- Jamie Winsor (<reset@riotgames.com>)
|
32
|
+
|
33
|
+
Thank you to all of our [Contributors](https://github.com/RiotGames/vagrant-berkshelf/graphs/contributors), testers, and users.
|
34
|
+
|
35
|
+
If you'd like to contribute, please see our [contribution guidelines](https://github.com/RiotGames/vagrant-berkshelf/blob/master/CONTRIBUTING.md) first.
|
data/Thorfile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'thor/rake_compat'
|
7
|
+
|
8
|
+
require 'berkshelf/vagrant'
|
9
|
+
|
10
|
+
class Default < Thor
|
11
|
+
class Gem < Thor
|
12
|
+
include Thor::RakeCompat
|
13
|
+
Bundler::GemHelper.install_tasks
|
14
|
+
|
15
|
+
namespace :gem
|
16
|
+
|
17
|
+
desc "build", "Build vagrant-berkshelf-#{Berkshelf::Vagrant::VERSION}.gem into the pkg directory"
|
18
|
+
def build
|
19
|
+
Rake::Task["build"].execute
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "release", "Create tag v#{Berkshelf::Vagrant::VERSION} and build and push vagrant-berkshelf-#{Berkshelf::Vagrant::VERSION}.gem to Rubygems"
|
23
|
+
def release
|
24
|
+
Rake::Task["release"].execute
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "install", "Build and install vagrant-berkshelf-#{Berkshelf::Vagrant::VERSION}.gem into system gems"
|
28
|
+
def install
|
29
|
+
Rake::Task["install"].execute
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Spec < Thor
|
34
|
+
include Thor::Actions
|
35
|
+
|
36
|
+
namespace :spec
|
37
|
+
default_task :unit
|
38
|
+
|
39
|
+
desc "ci", "Run all possible tests on Travis-CI"
|
40
|
+
def ci
|
41
|
+
ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing
|
42
|
+
invoke(:unit)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "unit", "Run unit tests"
|
46
|
+
def unit
|
47
|
+
unless run_unit
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
no_tasks do
|
53
|
+
def run_unit(*flags)
|
54
|
+
run "rspec --color --format=documentation #{flags.join(' ')} spec"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant Berkshelf plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'berkshelf'
|
8
|
+
require 'berkshelf/vagrant/version'
|
9
|
+
require 'berkshelf/vagrant/errors'
|
10
|
+
require 'tmpdir'
|
11
|
+
require 'fileutils'
|
12
|
+
|
13
|
+
module Berkshelf
|
14
|
+
# @author Jamie Winsor <reset@riotgames.com>
|
15
|
+
module Vagrant
|
16
|
+
autoload :Action, 'berkshelf/vagrant/action'
|
17
|
+
autoload :Config, 'berkshelf/vagrant/config'
|
18
|
+
autoload :Env, 'berkshelf/vagrant/env'
|
19
|
+
autoload :EnvHelpers, 'berkshelf/vagrant/env_helpers'
|
20
|
+
|
21
|
+
class << self
|
22
|
+
# The path to where shelfs are created on the host machine to be mounted in
|
23
|
+
# Vagrant guests
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
def shelf_path
|
27
|
+
File.join(Berkshelf.berkshelf_path, 'vagrant')
|
28
|
+
end
|
29
|
+
|
30
|
+
# Generate a new shelf to be mounted in a Vagrant guest
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
# path to the generated shelf
|
34
|
+
def mkshelf
|
35
|
+
unless File.exist?(shelf_path)
|
36
|
+
FileUtils.mkdir_p(shelf_path)
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir.mktmpdir('berkshelf-', shelf_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'berkshelf/vagrant/plugin'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Berkshelf
|
2
|
+
module Vagrant
|
3
|
+
module Action
|
4
|
+
autoload :Clean, 'berkshelf/vagrant/action/clean'
|
5
|
+
autoload :ConfigureChef, 'berkshelf/vagrant/action/configure_chef'
|
6
|
+
autoload :Install, 'berkshelf/vagrant/action/install'
|
7
|
+
autoload :LoadShelf, 'berkshelf/vagrant/action/load_shelf'
|
8
|
+
autoload :SetUI, 'berkshelf/vagrant/action/set_ui'
|
9
|
+
autoload :Upload, 'berkshelf/vagrant/action/upload'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Return the Berkshelf install middleware stack. When placed in the action chain
|
13
|
+
# this stack will find retrieve and resolve the cookbook dependencies describe
|
14
|
+
# in your configured Berksfile.
|
15
|
+
#
|
16
|
+
# Cookbooks will installed into a temporary directory, called a Shelf, and mounted
|
17
|
+
# into the VM. This mounted path will be appended to the chef_solo.cookbooks_path value.
|
18
|
+
#
|
19
|
+
# @return [::Vagrant::Action::Builder]
|
20
|
+
def install
|
21
|
+
@install ||= ::Vagrant::Action::Builder.new.tap do |b|
|
22
|
+
b.use Berkshelf::Vagrant::Action::Install
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return the Berkshelf upload middleware stack. When placed in the action chain
|
27
|
+
# this stack will upload cookbooks to a Chef Server if the Chef-Client provisioner
|
28
|
+
# is used. The Chef Server where the cookbooks will be uploaded to is the same Chef
|
29
|
+
# Server used in the Chef-Client provisioner.
|
30
|
+
#
|
31
|
+
# Nothing will be done if the Chef-Solo provisioner is used.
|
32
|
+
#
|
33
|
+
# @return [::Vagrant::Action::Builder]
|
34
|
+
def upload
|
35
|
+
@upload ||= ::Vagrant::Action::Builder.new.tap do |b|
|
36
|
+
b.use Berkshelf::Vagrant::Action::Upload
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Return the Berkshelf clean middleware stack. When placed in the action chain
|
41
|
+
# this stack will clean up any temporary directories or files created by the other
|
42
|
+
# middleware stacks.
|
43
|
+
#
|
44
|
+
# @return [::Vagrant::Action::Builder]
|
45
|
+
def clean
|
46
|
+
@clean ||= ::Vagrant::Action::Builder.new.tap do |b|
|
47
|
+
b.use setup
|
48
|
+
b.use Berkshelf::Vagrant::Action::Clean
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup
|
53
|
+
@setup ||= ::Vagrant::Action::Builder.new.tap do |b|
|
54
|
+
b.use ::Vagrant::Action::Builtin::EnvSet, berkshelf: Berkshelf::Vagrant::Env.new
|
55
|
+
b.use Berkshelf::Vagrant::Action::SetUI
|
56
|
+
b.use Berkshelf::Vagrant::Action::LoadShelf
|
57
|
+
b.use Berkshelf::Vagrant::Action::ConfigureChef
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Berkshelf
|
2
|
+
module Vagrant
|
3
|
+
module Action
|
4
|
+
# @author Jamie Winsor <reset@riotgames.com>
|
5
|
+
class Clean
|
6
|
+
include Berkshelf::Vagrant::EnvHelpers
|
7
|
+
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
if env[:berkshelf].shelf && File.exist?(env[:berkshelf].shelf)
|
14
|
+
env[:berkshelf].ui.info "Cleaning Vagrant's berkshelf"
|
15
|
+
|
16
|
+
FileUtils.remove_dir(env[:berkshelf].shelf, force: true)
|
17
|
+
FileUtils.rm_f(cache_file)
|
18
|
+
env[:berkshelf].shelf = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
rescue Berkshelf::BerkshelfError => e
|
23
|
+
raise Berkshelf::VagrantWrapperError.new(e)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Berkshelf
|
2
|
+
module Vagrant
|
3
|
+
module Action
|
4
|
+
# @author Jamie Winsor <reset@riotgames.com>
|
5
|
+
class ConfigureChef
|
6
|
+
include Berkshelf::Vagrant::EnvHelpers
|
7
|
+
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
unless berkshelf_enabled?(env)
|
14
|
+
return @app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
if chef_solo?(env) && shelf = env[:berkshelf].shelf
|
18
|
+
provisioners(:chef_solo, env).each do |provisioner|
|
19
|
+
provisioner.config.cookbooks_path = provisioner.config.send(:prepare_folders_config, shelf)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|