vagrant-puppet-library 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a40fa12b95eeef68a3b4e202cc2845678607f205
4
+ data.tar.gz: f1e35c8fadd547250460c74d7109faa1f5a37abb
5
+ SHA512:
6
+ metadata.gz: ce37bf64b39241cf24777ed8410c31fb19a8f725fb3d1813b8ac4ab1b0d3cc9186f147b486af66568b25e9de96054ec51f73a0a6ac2302b9366a9b31b5fc8a34
7
+ data.tar.gz: d551ecc08d896e467df4854f62a6a777d6ba606c6cb4d00ce73c656c0b565df4c9854df6010b2fd5fd054b7cb994704674c35064d3758d8adee67a08d2073bd0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1 @@
1
+ vagrant-development
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p353
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "vagrant-librarian-puppet"
11
+ gem "vagrant-puppet-library", path: "."
12
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Felix Gilcher
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
@@ -0,0 +1,29 @@
1
+ # Vagrant::Puppet::Library
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'vagrant-puppet-library'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install vagrant-puppet-library
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/vagrant-puppet-library/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
+ task :default => "spec"
@@ -0,0 +1,6 @@
1
+ # Add our custom translations to the load path
2
+ I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
3
+ I18n.reload!
4
+
5
+ require "vagrant-puppet-library/version"
6
+ require "vagrant-puppet-library/plugin"
@@ -0,0 +1,52 @@
1
+ require 'net/http'
2
+ require 'vagrant-puppet-library/error'
3
+
4
+ module VagrantPlugins
5
+ module PuppetLibrary
6
+ module Action
7
+ class BootPuppetLibrary
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ @env = env
12
+ end
13
+
14
+ def call(env)
15
+ config = env[:machine].config.puppet_library
16
+ return unless config.enabled?
17
+
18
+ env[:ui].info "Booting Puppet-Library, please stand by..."
19
+
20
+ t = Thread.new {
21
+ Rack::Server.start({
22
+ app: config.server,
23
+ Host: config.host,
24
+ Port: config.port,
25
+ })
26
+ }
27
+
28
+ host = config.host
29
+ host = '127.0.0.1' if config.host == '0.0.0.0' # 0.0.0.0 is bind to all interfaces
30
+
31
+ booted = false
32
+ tries = 0
33
+ while !booted
34
+ begin
35
+ Net::HTTP.start('127.0.0.1', config.port) {|http|
36
+ response = http.head('/')
37
+ }
38
+ booted = true
39
+ rescue Errno::ECONNREFUSED
40
+ sleep 1
41
+ end
42
+ tries += 1
43
+ raise ::VagrantPlugins::PuppetLibrary::Errors::BootFailure.new if tries > 30
44
+ end
45
+
46
+ env[:ui].info "Puppet Library booted and listening on #{config.host}:#{config.port}."
47
+
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,60 @@
1
+ module Command
2
+ class Forge < Vagrant. plugin(2, :command)
3
+
4
+ def self.synopsis
5
+ "Start the puppet-library server in the foreground to investigate the configuration"
6
+ end
7
+
8
+ def execute
9
+ options = {}
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: vagrant puppet-library <vm-name>"
12
+ opts.separator ""
13
+ end
14
+
15
+ argv = parse_options(opts)
16
+ return if !argv
17
+
18
+ vms = argv unless argv.empty?
19
+
20
+ configs = []
21
+ with_target_vms(vms) { |vm| configs.push vm.config.puppet_library }
22
+
23
+ configs.reject! {|c| !c.enabled?}
24
+
25
+ if (configs.count > 1)
26
+ boom("You have more than one VM defined. You need to tell me which you want.")
27
+ end
28
+
29
+ return if configs.first.nil?
30
+ config = configs.first
31
+
32
+
33
+ Rack::Server.start({
34
+ app: config.server,
35
+ Host: config.host,
36
+ Port: config.port,
37
+ })
38
+
39
+ 0
40
+ end
41
+
42
+ def boom(msg)
43
+ raise Vagrant::Errors::CLIInvalidOptions, :help => usage(msg)
44
+ end
45
+
46
+ def usage(msg); <<-EOS.gsub(/^ /, '')
47
+ ERROR: #{msg}
48
+
49
+ #{help}
50
+ EOS
51
+ end
52
+
53
+ def help; <<-EOS.gsub(/^ /, '')
54
+ vagrant puppet-library <vm-name>
55
+
56
+ EOS
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,88 @@
1
+ require "puppet_library"
2
+
3
+ module VagrantPlugins
4
+ module PuppetLibrary
5
+ class Config < Vagrant.plugin(2, :config)
6
+ attr_accessor :port
7
+ attr_accessor :host
8
+ attr_accessor :enabled
9
+ attr_accessor :module_dir
10
+ attr_accessor :sources
11
+
12
+ def initialize
13
+ @port = UNSET_VALUE
14
+ @host = UNSET_VALUE
15
+ @enabled = UNSET_VALUE
16
+ @sources = []
17
+ end
18
+
19
+ def finalize!
20
+ @port = 8080 if @port == UNSET_VALUE
21
+ @host = '0.0.0.0' if @host == UNSET_VALUE
22
+ end
23
+
24
+ def add_proxy(url, cache = false, cache_dir = nil)
25
+ #cache_dir ||= # provide a default here
26
+ if (cache)
27
+ @sources.push({type: :cache, url: url, path: cache_dir})
28
+ else
29
+ @sources.push({type: :proxy, url: url})
30
+ end
31
+ end
32
+
33
+ def add_module_dir(path)
34
+ @sources.push({type: :directory, path: path})
35
+ end
36
+
37
+ def add_source_dir(path)
38
+ @sources.push({type: :source, path: path})
39
+ end
40
+
41
+ def enabled?
42
+ @enabled
43
+ end
44
+
45
+ def enable!
46
+ @enabled = true
47
+ end
48
+
49
+ def disable!
50
+ @enabled = false
51
+ end
52
+
53
+ # Merge another configuration object into this one. This assumes that
54
+ # the other object is the same class as this one. This should not
55
+ # mutate this object, but instead should return a new, merged object.
56
+ #
57
+ # The default implementation will simply iterate over the instance
58
+ # variables and merge them together, with this object overriding
59
+ # any conflicting instance variables of the older object. Instance
60
+ # variables starting with "__" (double underscores) will be ignored.
61
+ # This lets you set some sort of instance-specific state on your
62
+ # configuration keys without them being merged together later.
63
+ #
64
+ # @param [Object] other The other configuration object to merge from,
65
+ # this must be the same type of object as this one.
66
+ # @return [Object] The merged object.
67
+ def merge(other)
68
+ result = super
69
+
70
+ result.sources = other.sources + self.sources
71
+ result
72
+ end
73
+
74
+
75
+ # retrieve the defined rack server from the config
76
+ def server
77
+ ::PuppetLibrary::Server.configure do
78
+ sources.each do |src|
79
+ type = src.delete(:type)
80
+ forge type do
81
+ src.each {|k, v| self.send(k, v) }
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,9 @@
1
+ module VagrantPlugins
2
+ module PuppetLibrary
3
+ module Errors
4
+ class BootFailure < ::Vagrant::Errors::VagrantError
5
+ error_key(:puppet_library_boot_failed)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant Puppet-Library plugin must be run within Vagrant."
5
+ end
6
+
7
+
8
+ module VagrantPlugins
9
+ module PuppetLibrary
10
+ class Plugin < Vagrant.plugin("2")
11
+ name "vagrant-puppet-library"
12
+ description <<-DESC
13
+ A Vagrant plugin to spin up a puppet library instance.
14
+ DESC
15
+ # action_hook "puppet_library" do |hook|
16
+ # # XXX see if we can only hook so long as a command option isn't passed
17
+ # hook.before Vagrant::Action::Builtin::Provision, Action::StartForge
18
+ # end
19
+
20
+ command("puppet-library", primary: false) do
21
+ require_relative "command/forge"
22
+ Command::Forge
23
+ end
24
+
25
+ action_hook "start_puppet_library" do |hook|
26
+ require_relative "action/boot_puppet_library"
27
+ hook.before VagrantPlugins::LibrarianPuppet::Action::Install, Action::BootPuppetLibrary
28
+ end
29
+
30
+ config "puppet_library" do
31
+ require_relative "config"
32
+ Config
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ module Vagrant
2
+ module Puppet
3
+ module Library
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ en:
2
+ vagrant:
3
+ errors:
4
+ puppet_library_boot_failed: "Booting the puppet library failed, please check host and port parameters."
5
+
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-puppet-library/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-puppet-library"
8
+ spec.version = Vagrant::Puppet::Library::VERSION
9
+ spec.authors = ["Felix Gilcher"]
10
+ spec.email = ["felix.gilcher@asquera.de"]
11
+ spec.license = 'MIT'
12
+ spec.homepage = "https://github.com/Asquera/vagrant-puppet-library"
13
+ spec.summary = %q{Run puppet-library in your Vagrantfiles}
14
+ spec.description = %q{A plugin to vagrant that allows running a private puppetforge (puppet-library) inside a vagrant env.}
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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"]
20
+
21
+ spec.add_dependency "puppet-library", "~> 0.13"
22
+ spec.add_dependency "i18n"
23
+ spec.add_dependency "log4r"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.5"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec-core", "~> 2.12.2"
28
+ spec.add_development_dependency "rspec-expectations", "~> 2.12.1"
29
+ spec.add_development_dependency "rspec-mocks", "~> 2.12.1"
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-puppet-library
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix Gilcher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: puppet-library
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: i18n
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: log4r
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.12.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 2.12.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-expectations
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-mocks
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.12.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.12.1
125
+ description: A plugin to vagrant that allows running a private puppetforge (puppet-library)
126
+ inside a vagrant env.
127
+ email:
128
+ - felix.gilcher@asquera.de
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .ruby-gemset
135
+ - .ruby-version
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - lib/vagrant-puppet-library.rb
141
+ - lib/vagrant-puppet-library/action/boot_puppet_library.rb
142
+ - lib/vagrant-puppet-library/command/forge.rb
143
+ - lib/vagrant-puppet-library/config.rb
144
+ - lib/vagrant-puppet-library/error.rb
145
+ - lib/vagrant-puppet-library/plugin.rb
146
+ - lib/vagrant-puppet-library/version.rb
147
+ - locales/en.yml
148
+ - vagrant-puppet-library.gemspec
149
+ homepage: https://github.com/Asquera/vagrant-puppet-library
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.2.2
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Run puppet-library in your Vagrantfiles
173
+ test_files: []