vagrant-librarian-puppet 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ Puppetfile.lock
19
+ modules
20
+ .vagrant
21
+ .tmp
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in ..gemspec
4
3
  gemspec
4
+
5
+ group :development do
6
+ gem "vagrant", github: "mitchellh/vagrant"
7
+ gem "debugger"
8
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Gareth Rushgrove
1
+ Copyright (c) 2013 Jimmy Cuadra
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,13 +1,61 @@
1
+ # vagrant-librarian-puppet
1
2
 
2
- Simple Vagrant middleware which runs `librarian-puppet install` before
3
- each `vagrant up` and `vagrant provision`.
3
+ A [Vagrant](http://www.vagrantup.com/) plugin to install
4
+ [Puppet](http://docs.puppetlabs.com/#puppetpuppet) modules using
5
+ [Librarian-Puppet](https://github.com/rodjek/librarian-puppet).
4
6
 
5
- To install you can run
7
+ ## Requirements
6
8
 
7
- vagrant gem install librarian-puppet-vagrant
9
+ * Vagrant version 1.2.0 or greater.
8
10
 
9
- It's up to you to make sure you have librarian puppet installed and
10
- available on your path. To use this just add the following to your
11
- Vagrantfile:
11
+ ## Installation
12
12
 
13
- require 'librarian/puppet/vagrant'
13
+ ``` bash
14
+ vagrant plugin install vagrant-librarian-puppet
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Vagrant will automatically run Librarian-Puppet before any provisioning step, so
20
+ simply set up your Puppetfile as you normally would.
21
+
22
+ You may specify the subdirectory within which to run `librarian-puppet`
23
+ using the `librarian_puppet.puppetfile_dir` config key. Please keep in mind
24
+ that you will need to explicitly set the `modules` path in the
25
+ `:puppet` provisioner and this path must exist before running vagrant commands.
26
+
27
+ **NOTE:** Since the puppet provisioner will fail if the path provided to
28
+ "puppet.modules" doesn't exist and librarian-puppet will destroy and recreate
29
+ the modules directory on each run, this plugin supports a placeholder file
30
+ within the modules directory that can be checked into version control and will
31
+ persist between provisions.
32
+
33
+ ```ruby
34
+ Vagrant.configure("2") do |config|
35
+
36
+ config.librarian_puppet.puppetfile_dir = "puppet"
37
+ # placeholder_filename defaults to .PLACEHOLDER
38
+ config.librarian_puppet.placeholder_filename = ".MYPLACEHOLDER"
39
+
40
+ config.vm.provision :puppet do |puppet|
41
+ puppet.modules = "puppet/modules"
42
+
43
+ ...
44
+
45
+ end
46
+ end
47
+ ```
48
+
49
+ ## Development
50
+
51
+ ``` bash
52
+ bundle
53
+ bundle exec vagrant up
54
+ ```
55
+
56
+ ## Acknowledgements
57
+
58
+ Thanks to @jimmycuadra and other contributors for their work on
59
+ [vagrant-librarian-chef](https://github.com/jimmycuadra/vagrant-librarian-chef).
60
+ This plugin made some slight changes to work with puppet, but largely just used
61
+ their code.
data/Vagrantfile ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ Vagrant.require_plugin 'vagrant-librarian-puppet'
6
+
7
+ Vagrant.configure('2') do |config|
8
+ config.vm.box = 'precise64'
9
+ config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
10
+
11
+ config.librarian_puppet.puppetfile_dir = 'puppet'
12
+
13
+ config.vm.provision :puppet do |puppet|
14
+ puppet.manifests_path = 'manifests'
15
+ puppet.manifest_file = 'init.pp'
16
+ puppet.module_path = 'puppet/modules'
17
+ end
18
+
19
+ end
@@ -0,0 +1,2 @@
1
+ require "vagrant-librarian-puppet/version"
2
+ require "vagrant-librarian-puppet/plugin"
@@ -0,0 +1,71 @@
1
+ require 'librarian/puppet'
2
+ require 'librarian/action'
3
+
4
+ module VagrantPlugins
5
+ module LibrarianPuppet
6
+ module Action
7
+ class Install
8
+ def initialize(app, env)
9
+ @app = app
10
+ @env = env
11
+ # Config#finalize! SHOULD be called automatically
12
+ env[:global_config].librarian_puppet.finalize!
13
+ end
14
+
15
+ def call(env)
16
+ config = env[:global_config].librarian_puppet
17
+ if
18
+ provisioned? and
19
+ File.exist? File.join(env[:root_path], config.puppetfile_path)
20
+
21
+ env[:ui].info "Installing Puppet modules with Librarian-Puppet..."
22
+
23
+ # NB: Librarian::Puppet::Environment calls `which puppet` so we
24
+ # need to make sure VAGRANT_HOME/gems/bin has been added to the
25
+ # path.
26
+ original_path = ENV['PATH']
27
+ bin_path = env[:gems_path].join('bin')
28
+ ENV['PATH'] = "#{bin_path}#{::File::PATH_SEPARATOR}#{ENV['PATH']}"
29
+
30
+ # Determine if we need to persist placeholder file
31
+ placeholder_file = File.join(
32
+ env[:root_path],
33
+ config.puppetfile_dir,
34
+ 'modules',
35
+ config.placeholder_filename
36
+ )
37
+ if File.exist? placeholder_file
38
+ placeholder_contents = File.read(placeholder_file)
39
+ else
40
+ placeholder_contents = nil
41
+ end
42
+
43
+ environment = Librarian::Puppet::Environment.new({
44
+ :project_path => File.join(env[:root_path], config.puppetfile_dir)
45
+ })
46
+ Librarian::Action::Ensure.new(environment).run
47
+ Librarian::Action::Resolve.new(environment).run
48
+ Librarian::Action::Install.new(environment).run
49
+
50
+ # Restore the original path
51
+ ENV['PATH'] = original_path
52
+
53
+ # Persist placeholder if necessary
54
+ if placeholder_contents != nil
55
+ File.open(placeholder_file, 'w') { |file|
56
+ file.write(placeholder_contents)
57
+ }
58
+ end
59
+
60
+ end
61
+ @app.call(env)
62
+ end
63
+
64
+ def provisioned?
65
+ @env[:provision_enabled].nil? ? true : @env[:provision_enabled]
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module LibrarianPuppet
3
+ class Config < Vagrant.plugin(2, :config)
4
+ attr_accessor :puppetfile_dir
5
+ attr_accessor :placeholder_filename
6
+
7
+ def initialize
8
+ @puppetfile_dir = UNSET_VALUE
9
+ @placeholder_filename = UNSET_VALUE
10
+ end
11
+
12
+ def finalize!
13
+ @puppetfile_dir = '.' if @puppetfile_dir == UNSET_VALUE
14
+ @placeholder_filename = '.PLACEHOLDER' if @placeholder_filename == UNSET_VALUE
15
+ end
16
+
17
+ def puppetfile_path
18
+ @puppetfile_path ||= @puppetfile_dir ? File.join(@puppetfile_dir, 'Puppetfile') : 'Puppetfile'
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ abort "vagrant-librarian-puppet must be loaded in a Vagrant environment."
5
+ end
6
+
7
+ require "vagrant-librarian-puppet/action/librarian_puppet"
8
+
9
+
10
+ module VagrantPlugins
11
+ module LibrarianPuppet
12
+ class Plugin < Vagrant.plugin("2")
13
+ name "vagrant-librarian-puppet"
14
+ description <<-DESC
15
+ A Vagrant plugin to install Puppet modules using Librarian-Puppet.
16
+ DESC
17
+ action_hook "librarian_puppet" do |hook|
18
+ # XXX see if we can only hook so long as a command option isn't passed
19
+ hook.before Vagrant::Action::Builtin::Provision, Action::Install
20
+ end
21
+
22
+ config "librarian_puppet" do
23
+ require_relative "config"
24
+ Config
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module LibrarianPuppet
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
data/manifests/init.pp ADDED
@@ -0,0 +1,8 @@
1
+ class dev {
2
+
3
+ include git
4
+ include supervisor
5
+
6
+ }
7
+
8
+ include dev
data/puppet/Puppetfile ADDED
@@ -0,0 +1,8 @@
1
+ # Manage Puppet module dependencies with librarian-puppet
2
+
3
+ forge 'http://forge.puppetlabs.com'
4
+
5
+ mod 'supervisor',
6
+ :git => 'git://github.com/eventbrite/puppet-supervisor.git'
7
+
8
+ mod 'puppetlabs/git'
@@ -1,19 +1,27 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-librarian-puppet/version'
3
5
 
4
- require 'librarian/puppet/vagrant/version'
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-librarian-puppet"
8
+ spec.version = VagrantPlugins::LibrarianPuppet::VERSION
9
+ spec.authors = ["Michael Hahn"]
10
+ spec.email = ["mwhahn@gmail.com"]
11
+ spec.description = %q{A Vagrant plugin to install Puppet modules using Librarian-Puppet.}
12
+ spec.summary = %q{A Vagrant plugin to install Puppet modules using Librarian-Puppet.}
13
+ spec.homepage = "https://github.com/mhahn/vagrant-librarian-puppet"
14
+ spec.license = "MIT"
5
15
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "vagrant-librarian-puppet"
8
- gem.version = Librarian::Puppet::Vagrant::VERSION
9
- gem.authors = ["Gareth Rushgrove"]
10
- gem.email = ["gareth@morethanseven.net"]
11
- gem.description = "A middleware for vagrant to run librarian-puppet before up"
12
- gem.summary = "Vagrant middleware for people working with librarian-puppet"
13
- gem.homepage = "https://github.com/garethr/vagrant-librarian-puppet"
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
14
20
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
21
+ spec.add_runtime_dependency "librarian-puppet"
22
+ spec.add_runtime_dependency "librarian"
23
+ spec.add_runtime_dependency "puppet"
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
19
27
  end
metadata CHANGED
@@ -1,71 +1,156 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vagrant-librarian-puppet
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - Gareth Rushgrove
7
+ authors:
8
+ - Michael Hahn
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2013-02-28 00:00:00 -05:00
18
- default_executable:
19
- dependencies: []
20
-
21
- description: A middleware for vagrant to run librarian-puppet before up
22
- email:
23
- - gareth@morethanseven.net
12
+ date: 2013-10-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: librarian-puppet
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: librarian
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: puppet
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.3'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A Vagrant plugin to install Puppet modules using Librarian-Puppet.
111
+ email:
112
+ - mwhahn@gmail.com
24
113
  executables: []
25
-
26
114
  extensions: []
27
-
28
115
  extra_rdoc_files: []
29
-
30
- files:
116
+ files:
31
117
  - .gitignore
32
118
  - Gemfile
33
119
  - LICENSE.txt
34
120
  - README.md
35
121
  - Rakefile
36
- - lib/..rb
37
- - lib/librarian/puppet/vagrant.rb
38
- - lib/librarian/puppet/vagrant/version.rb
122
+ - Vagrantfile
123
+ - lib/vagrant-librarian-puppet.rb
124
+ - lib/vagrant-librarian-puppet/action/librarian_puppet.rb
125
+ - lib/vagrant-librarian-puppet/config.rb
126
+ - lib/vagrant-librarian-puppet/plugin.rb
127
+ - lib/vagrant-librarian-puppet/version.rb
128
+ - manifests/init.pp
129
+ - puppet/Puppetfile
39
130
  - vagrant-librarian-puppet.gemspec
40
- has_rdoc: true
41
- homepage: https://github.com/garethr/vagrant-librarian-puppet
42
- licenses: []
43
-
131
+ homepage: https://github.com/mhahn/vagrant-librarian-puppet
132
+ licenses:
133
+ - MIT
44
134
  post_install_message:
45
135
  rdoc_options: []
46
-
47
- require_paths:
136
+ require_paths:
48
137
  - lib
49
- required_ruby_version: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
- version: "0"
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
63
150
  requirements: []
64
-
65
151
  rubyforge_project:
66
- rubygems_version: 1.3.6
152
+ rubygems_version: 1.8.23
67
153
  signing_key:
68
154
  specification_version: 3
69
- summary: Vagrant middleware for people working with librarian-puppet
155
+ summary: A Vagrant plugin to install Puppet modules using Librarian-Puppet.
70
156
  test_files: []
71
-
data/lib/..rb DELETED
@@ -1,5 +0,0 @@
1
- require "./version"
2
-
3
- module .
4
- # Your code goes here...
5
- end
@@ -1,23 +0,0 @@
1
- module Librarian
2
- module Puppet
3
- module Vagrant
4
- class Middleware
5
- def initialize(app, env)
6
- @app = app
7
- end
8
- def call(env)
9
- env[:ui].info 'Running librarian puppet'
10
- result = system 'librarian-puppet install'
11
- unless result
12
- env[:ui].error 'Librarian Puppet failed to run, do you have a valid Puppetfile?'
13
- exit
14
- end
15
- @app.call(env)
16
- end
17
- end
18
- end
19
- end
20
- end
21
-
22
- Vagrant.actions[:up].insert(Vagrant::Action::VM::Provision, Librarian::Puppet::Vagrant::Middleware)
23
- Vagrant.actions[:provision].insert(Vagrant::Action::VM::Provision, Librarian::Puppet::Vagrant::Middleware)
@@ -1,7 +0,0 @@
1
- module Librarian
2
- module Puppet
3
- module Vagrant
4
- VERSION = "0.0.1"
5
- end
6
- end
7
- end