vagrant-puppetconf 0.1.1

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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-puppetconf.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Glenn Poston
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.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Vagrant::Puppetconf
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'vagrant-puppetconf'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install vagrant-puppetconf
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ module VagrantPuppetconf
2
+ class Config < Vagrant::Config::Base
3
+ attr_accessor :updates
4
+ attr_accessor :update_only
5
+
6
+ def update_only
7
+ @update_only.nil? ? (@update_only = true) : @update_only
8
+ end
9
+
10
+ def validate(env, errors)
11
+ errors.add("Updates should be passed as a hash") unless updates.kind_of? Hash
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,44 @@
1
+ module VagrantPuppetconf
2
+ class Middleware
3
+ def initialize(app, env)
4
+ @app = app
5
+ @env = env
6
+ end
7
+
8
+ def call(env)
9
+ @env = env
10
+ create_puppet_conf unless puppet_conf_exists?
11
+ install_augeas unless puppet_conf_exists? unless augeas_installed?
12
+ update
13
+ @app.call env
14
+ end
15
+
16
+ def update
17
+ unless @env[:vm].config.puppetconf.update_only
18
+ @env[:vm].channel.sudo("cp /dev/null /etc/puppet/puppet.conf")
19
+ end
20
+ @env[:vm].config.puppetconf.updates.each_pair do |path, value|
21
+ @env[:vm].channel.execute("echo -e 'set /files/etc/puppet/puppet.conf/#{path} #{value} \n save' | sudo augtool")
22
+ end
23
+ end
24
+
25
+ def puppet_conf_exists?
26
+ @env[:vm].channel.execute("ls /etc/puppet/puppet.conf", :error_check => false) == 0
27
+ end
28
+
29
+ def create_puppet_conf
30
+ @env[:ui].warn I18n.t('vagrant.plugins.puppetconf.middleware.create_puppetconf')
31
+ @env[:vm].channel.sudo("mkdir -p /etc/puppet")
32
+ @env[:vm].channel.sudo("touch /etc/puppet/puppet.conf")
33
+ end
34
+
35
+ def augeas_installed?
36
+ @env[:vm].channel.execute("dpkg -l | grep augeas-tools", :error_check => false) == 0
37
+ end
38
+
39
+ def install_augeas
40
+ @env[:ui].warn I18n.t('vagrant.plugins.puppetconf.middleware.install_augeas')
41
+ @env[:vm].channel.sudo("apt-get install augeas-tools")
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Puppetconf
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'vagrant'
2
+ require 'vagrant-puppetconf/middleware'
3
+ require 'vagrant-puppetconf/config'
4
+
5
+ Vagrant.config_keys.register(:puppetconf) { VagrantPuppetconf::Config }
6
+
7
+ Vagrant.actions[:start].use VagrantPuppetconf::Middleware
8
+
9
+ I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
@@ -0,0 +1 @@
1
+ require 'vagrant-puppetconf'
data/locales/en.yml ADDED
@@ -0,0 +1,7 @@
1
+ en:
2
+ vagrant:
3
+ plugins:
4
+ puppetconf:
5
+ middleware:
6
+ create_puppetconf: "Creating puppet.conf"
7
+ install_augeas: "Installing augeas-tools"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/vagrant-puppetconf/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Glenn Poston"]
6
+ gem.email = ["gposton1040@gmail.com"]
7
+ gem.description = %q{Vagrant plugin which allows manipulation of puppet.conf from VagrantFile}
8
+ gem.summary = %q{Vagrant plugin which allows manipulation of puppet.conf from VagrantFile}
9
+ gem.homepage = "https://github.com/gposton/vagrant-puppetconf"
10
+
11
+ gem.add_development_dependency "vagrant"
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "vagrant-puppetconf"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = Vagrant::Puppetconf::VERSION
19
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-puppetconf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Glenn Poston
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: vagrant
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
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
+ description: Vagrant plugin which allows manipulation of puppet.conf from VagrantFile
31
+ email:
32
+ - gposton1040@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - lib/vagrant-puppetconf.rb
42
+ - lib/vagrant-puppetconf/config.rb
43
+ - lib/vagrant-puppetconf/middleware.rb
44
+ - lib/vagrant-puppetconf/version.rb
45
+ - lib/vagrant_init.rb
46
+ - locales/en.yml
47
+ - vagrant-puppetconf.gemspec
48
+ homepage: https://github.com/gposton/vagrant-puppetconf
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Vagrant plugin which allows manipulation of puppet.conf from VagrantFile
72
+ test_files: []