guard-puppet 0.0.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/.gitignore +4 -0
- data/Gemfile +9 -0
- data/Guardfile +9 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/guard-puppet.gemspec +26 -0
- data/lib/guard/puppet.rb +31 -0
- data/lib/guard/puppet/runner.rb +32 -0
- data/lib/guard/puppet/templates/Guardfile +4 -0
- data/lib/guard/puppet/version.rb +5 -0
- data/spec/lib/guard/puppet/runner_spec.rb +35 -0
- data/spec/lib/guard/puppet_spec.rb +32 -0
- data/spec/spec_helper.rb +4 -0
- metadata +114 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Reapply your Puppet configs automatically using Guard! Awesome!
|
2
|
+
|
3
|
+
``` ruby
|
4
|
+
guard 'puppet', :verbose => true, :manifest => 'manifests/site.pp' do
|
5
|
+
watch(%r{^(manifests|modules)})
|
6
|
+
end
|
7
|
+
```
|
8
|
+
|
9
|
+
It's assumed your configs are all in the current folder, which is the
|
10
|
+
equivalent of `--confdir=$PWD` at the command line. Otherwise,
|
11
|
+
there's not much use of using Guard with Puppet. :)
|
12
|
+
|
13
|
+
Two options so far:
|
14
|
+
|
15
|
+
* `:verbose`: Show more output from Puppet (default: `true`)
|
16
|
+
* `:manifest`: The main manifest file to run (default: `manifests/site.pp`)
|
17
|
+
|
18
|
+
Bugs and fixes? You know the drill.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "guard/puppet/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "guard-puppet"
|
7
|
+
s.version = Guard::PuppetVersion::VERSION
|
8
|
+
s.authors = ["John Bintz"]
|
9
|
+
s.email = ["john@coswellproductions.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Reapply Puppet configs automatically using Guard.}
|
12
|
+
s.description = %q{Reapply Puppet configs automatically using Guard.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "guard-puppet"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'guard'
|
22
|
+
s.add_dependency 'puppet'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rspec', '~> 2.6.0'
|
25
|
+
s.add_development_dependency 'mocha'
|
26
|
+
end
|
data/lib/guard/puppet.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'guard/guard'
|
2
|
+
|
3
|
+
module ::Guard
|
4
|
+
class Puppet < ::Guard::Guard
|
5
|
+
class << self
|
6
|
+
attr_accessor :is_wrapping_exit
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(watchers = [], options = {})
|
10
|
+
super
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_all
|
15
|
+
UI.info(msg = "Applying Puppet configuration...")
|
16
|
+
Notifier.notify msg, :title => "Puppet Config", :image => :pending
|
17
|
+
if Runner.new(@options).run != 0
|
18
|
+
Notifier.notify(msg = "Puppet config failure!", :title => "Puppet Config", :image => :failed)
|
19
|
+
else
|
20
|
+
Notifier.notify(msg = "Puppet config reapplied successfully!", :title => "Puppet Config")
|
21
|
+
end
|
22
|
+
UI.info(msg)
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_on_change(files = [])
|
26
|
+
run_all
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'guard/puppet/runner'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'guard/puppet'
|
2
|
+
require 'puppet/util/command_line'
|
3
|
+
require 'puppet/application/apply'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Puppet
|
7
|
+
class Runner
|
8
|
+
attr_reader :options
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = {
|
12
|
+
:verbose => true,
|
13
|
+
:manifest => 'manifests/site.pp'
|
14
|
+
}.merge(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
::Puppet::Util::CommandLine.new('puppet', command_line_params).execute
|
19
|
+
0
|
20
|
+
rescue SystemExit => e
|
21
|
+
e.status
|
22
|
+
end
|
23
|
+
|
24
|
+
def command_line_params
|
25
|
+
command = [ "apply", %{--confdir="#{Dir.pwd}"} ]
|
26
|
+
command << "-v" if @options[:verbose]
|
27
|
+
command << @options[:manifest] if @options[:manifest]
|
28
|
+
command
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'guard/puppet/runner'
|
3
|
+
|
4
|
+
describe Guard::Puppet::Runner do
|
5
|
+
let(:options) { {} }
|
6
|
+
let(:runner) { described_class.new(options) }
|
7
|
+
|
8
|
+
describe '#command_line_params' do
|
9
|
+
subject { runner.command_line_params }
|
10
|
+
|
11
|
+
context 'default' do
|
12
|
+
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', 'manifests/site.pp' ] }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'not verbose' do
|
16
|
+
let(:options) { { :verbose => false } }
|
17
|
+
|
18
|
+
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, 'manifests/site.pp' ] }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'manifest' do
|
22
|
+
let(:options) { { :manifest => '123' } }
|
23
|
+
|
24
|
+
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', '123' ] }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#run' do
|
29
|
+
it 'should return the result of an exit call' do
|
30
|
+
::Puppet::Util::CommandLine.expects(:new).raises(SystemExit.new(10))
|
31
|
+
|
32
|
+
runner.run.should == 10
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'guard/puppet'
|
3
|
+
|
4
|
+
describe Guard::Puppet do
|
5
|
+
let(:guard) { described_class.new }
|
6
|
+
|
7
|
+
describe '#run_all' do
|
8
|
+
before do
|
9
|
+
Guard::UI.stubs(:info)
|
10
|
+
Guard::Notifier.expects(:notify).with("Applying Puppet configuration...", { :image => :pending, :title => "Puppet Config" })
|
11
|
+
Guard::Puppet::Runner.any_instance.expects(:run).returns(return_value)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'fails' do
|
15
|
+
let(:return_value) { 1 }
|
16
|
+
|
17
|
+
it 'should show the failure message' do
|
18
|
+
Guard::Notifier.expects(:notify).with("Puppet config failure!", :image => :failed, :title => "Puppet Config")
|
19
|
+
guard.run_all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'succeeds' do
|
24
|
+
let(:return_value) { 0 }
|
25
|
+
|
26
|
+
it 'should show the success message' do
|
27
|
+
Guard::Notifier.expects(:notify).with("Puppet config reapplied successfully!", :title => "Puppet Config")
|
28
|
+
guard.run_all
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-puppet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Bintz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-05 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: guard
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: puppet
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.6.0
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: mocha
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
description: Reapply Puppet configs automatically using Guard.
|
61
|
+
email:
|
62
|
+
- john@coswellproductions.com
|
63
|
+
executables: []
|
64
|
+
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files: []
|
68
|
+
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- Guardfile
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- guard-puppet.gemspec
|
76
|
+
- lib/guard/puppet.rb
|
77
|
+
- lib/guard/puppet/runner.rb
|
78
|
+
- lib/guard/puppet/templates/Guardfile
|
79
|
+
- lib/guard/puppet/version.rb
|
80
|
+
- spec/lib/guard/puppet/runner_spec.rb
|
81
|
+
- spec/lib/guard/puppet_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: ""
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project: guard-puppet
|
107
|
+
rubygems_version: 1.6.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Reapply Puppet configs automatically using Guard.
|
111
|
+
test_files:
|
112
|
+
- spec/lib/guard/puppet/runner_spec.rb
|
113
|
+
- spec/lib/guard/puppet_spec.rb
|
114
|
+
- spec/spec_helper.rb
|