shadow_puppet 0.4.1 → 0.5.2
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/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +62 -0
- data/README.rdoc +3 -4
- data/Rakefile +11 -14
- data/bin/shadow_puppet +9 -6
- data/lib/shadow_puppet/manifest.rb +34 -85
- data/lib/shadow_puppet/test.rb +12 -13
- data/shadow_puppet.gemspec +31 -19
- data/spec/cli_spec.rb +16 -0
- data/spec/fixtures/cli_spec_manifest.rb +7 -0
- data/spec/fixtures/manifests.rb +48 -1
- data/spec/manifest_spec.rb +72 -14
- data/spec/spec_helper.rb +11 -8
- data/spec/test_spec.rb +6 -13
- data/spec/type_spec.rb +1 -3
- metadata +104 -53
- data/IsolateScenarios +0 -11
- data/spec/spec.opts +0 -4
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--debugger --require ./spec/spec_helper.rb --backtrace --color --format d
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'puppet', '2.7.3'
|
4
|
+
gem 'highline', '>= 1.5.0'
|
5
|
+
gem 'builder', '>= 2.1.2'
|
6
|
+
gem 'activesupport', '>= 2.0.0'
|
7
|
+
gem 'i18n', '>= 0.5.0'
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem "rspec", "~> 2.6.0"
|
11
|
+
gem "rspec-core", "~> 2.6.0"
|
12
|
+
gem "jeweler", "~> 1.6.2"
|
13
|
+
gem 'ruby-debug', :platforms => :ruby_18
|
14
|
+
gem 'ruby-debug19', :platforms => :ruby_19
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.10)
|
5
|
+
archive-tar-minitar (0.5.2)
|
6
|
+
builder (2.1.2)
|
7
|
+
columnize (0.3.4)
|
8
|
+
diff-lcs (1.1.3)
|
9
|
+
facter (1.6.0)
|
10
|
+
git (1.2.5)
|
11
|
+
highline (1.5.2)
|
12
|
+
i18n (0.6.0)
|
13
|
+
jeweler (1.6.4)
|
14
|
+
bundler (~> 1.0)
|
15
|
+
git (>= 1.2.5)
|
16
|
+
rake
|
17
|
+
linecache (0.46)
|
18
|
+
rbx-require-relative (> 0.0.4)
|
19
|
+
linecache19 (0.5.12)
|
20
|
+
ruby_core_source (>= 0.1.4)
|
21
|
+
puppet (2.7.3)
|
22
|
+
facter (>= 1.5.1)
|
23
|
+
rake (0.9.2)
|
24
|
+
rbx-require-relative (0.0.5)
|
25
|
+
rspec (2.6.0)
|
26
|
+
rspec-core (~> 2.6.0)
|
27
|
+
rspec-expectations (~> 2.6.0)
|
28
|
+
rspec-mocks (~> 2.6.0)
|
29
|
+
rspec-core (2.6.4)
|
30
|
+
rspec-expectations (2.6.0)
|
31
|
+
diff-lcs (~> 1.1.2)
|
32
|
+
rspec-mocks (2.6.0)
|
33
|
+
ruby-debug (0.10.4)
|
34
|
+
columnize (>= 0.1)
|
35
|
+
ruby-debug-base (~> 0.10.4.0)
|
36
|
+
ruby-debug-base (0.10.4)
|
37
|
+
linecache (>= 0.3)
|
38
|
+
ruby-debug-base19 (0.11.25)
|
39
|
+
columnize (>= 0.3.1)
|
40
|
+
linecache19 (>= 0.5.11)
|
41
|
+
ruby_core_source (>= 0.1.4)
|
42
|
+
ruby-debug19 (0.11.6)
|
43
|
+
columnize (>= 0.3.1)
|
44
|
+
linecache19 (>= 0.5.11)
|
45
|
+
ruby-debug-base19 (>= 0.11.19)
|
46
|
+
ruby_core_source (0.1.5)
|
47
|
+
archive-tar-minitar (>= 0.5.2)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
activesupport (>= 2.0.0)
|
54
|
+
builder (>= 2.1.2)
|
55
|
+
highline (>= 1.5.0)
|
56
|
+
i18n (>= 0.5.0)
|
57
|
+
jeweler (~> 1.6.2)
|
58
|
+
puppet (= 2.7.3)
|
59
|
+
rspec (~> 2.6.0)
|
60
|
+
rspec-core (~> 2.6.0)
|
61
|
+
ruby-debug
|
62
|
+
ruby-debug19
|
data/README.rdoc
CHANGED
@@ -12,7 +12,6 @@ ShadowPuppet::Manifest.
|
|
12
12
|
|
13
13
|
== Running the Test Suite
|
14
14
|
|
15
|
-
$ gem install
|
16
|
-
$
|
17
|
-
|
18
|
-
$ isolate-scenarios rake spec
|
15
|
+
$ gem install bundler
|
16
|
+
$ bundle install
|
17
|
+
$ bundle exec rake spec
|
data/Rakefile
CHANGED
@@ -5,24 +5,15 @@ Jeweler::Tasks.new do |gem|
|
|
5
5
|
gem.name = "shadow_puppet"
|
6
6
|
gem.summary = %Q{A Ruby Puppet DSL}
|
7
7
|
gem.description = %Q{A Ruby Puppet DSL}
|
8
|
-
gem.email = "
|
8
|
+
gem.email = "will@railsmachine.com"
|
9
9
|
gem.homepage = "http://railsmachine.github.com/shadow_puppet"
|
10
10
|
gem.rubyforge_project = "moonshine"
|
11
|
-
gem.authors = ["Jesse Newland", "Josh Nichols", "Eric Lindvall", "Lee Jones", "dreamcat4", "Patrick Schless", "Ches Martin", "Rob Lingle", "Scott Fleckenstein"
|
11
|
+
gem.authors = ["Jesse Newland", "Josh Nichols", "Eric Lindvall", "Lee Jones", "Will Farrington", "dreamcat4", "Patrick Schless", "Ches Martin", "Rob Lingle", "Scott Fleckenstein"]
|
12
12
|
|
13
|
-
gem.version = "0.
|
14
|
-
|
15
|
-
gem.add_dependency('puppet', ["= 0.24.8"])
|
16
|
-
gem.add_dependency('facter', [">= 1.5.4"])
|
17
|
-
gem.add_dependency('highline', [">= 1.5.0"])
|
18
|
-
gem.add_dependency('builder', [">= 2.1.2"])
|
19
|
-
gem.add_dependency('activesupport', [">= 2.0.0"])
|
13
|
+
gem.version = "0.5.2"
|
20
14
|
|
21
15
|
gem.rdoc_options << '--inline-source' << '--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/'
|
22
16
|
|
23
|
-
gem.add_development_dependency "rspec", ">= 0"
|
24
|
-
gem.add_development_dependency "isolate-scenarios", ">= 0"
|
25
|
-
|
26
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
27
18
|
end
|
28
19
|
Jeweler::GemcutterTasks.new
|
@@ -46,9 +37,15 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
46
37
|
rdoc.options << '--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/'
|
47
38
|
end
|
48
39
|
|
40
|
+
require 'rspec/core/rake_task'
|
41
|
+
|
42
|
+
desc 'Default: run specs.'
|
49
43
|
task :default => :spec
|
50
|
-
|
51
|
-
|
44
|
+
|
45
|
+
desc "Run specs"
|
46
|
+
RSpec::Core::RakeTask.new do |t|
|
47
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
48
|
+
# Put spec opts in a file named .rspec in root
|
52
49
|
end
|
53
50
|
|
54
51
|
task :build => :cleanup do
|
data/bin/shadow_puppet
CHANGED
@@ -102,18 +102,19 @@ begin
|
|
102
102
|
|
103
103
|
opts.parse!
|
104
104
|
|
105
|
+
# Take any variables set on the command line and update ENV
|
106
|
+
ARGV.delete_if do |arg|
|
107
|
+
next unless arg =~ /^(\w+)=(.*)$/
|
108
|
+
ENV[$1] = $2
|
109
|
+
end
|
110
|
+
|
105
111
|
unless filename = ARGV[0]
|
106
112
|
puts "Error: Manifest filename must be provided\n\n"
|
107
113
|
puts opts
|
108
114
|
exit(1)
|
109
|
-
# Take any variables set on the command line and update ENV
|
110
|
-
ARGV.delete_if do |arg|
|
111
|
-
next unless arg =~ /^(\w+)=(.*)$/
|
112
|
-
ENV[$1] = $2
|
113
|
-
end
|
114
115
|
end
|
115
116
|
|
116
|
-
|
117
|
+
$LOAD_PATH.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
117
118
|
require 'shadow_puppet/core_ext'
|
118
119
|
require 'shadow_puppet'
|
119
120
|
require 'fileutils'
|
@@ -123,6 +124,8 @@ begin
|
|
123
124
|
Puppet[:show_diff] = true
|
124
125
|
end
|
125
126
|
|
127
|
+
Puppet::Util::Log.newdestination(:console)
|
128
|
+
|
126
129
|
klass = File.basename(filename, ".rb")
|
127
130
|
require filename
|
128
131
|
manifest = klass.camelize.constantize.new
|
@@ -75,7 +75,7 @@ module ShadowPuppet
|
|
75
75
|
|
76
76
|
class_inheritable_accessor :recipes
|
77
77
|
write_inheritable_attribute(:recipes, [])
|
78
|
-
attr_reader :
|
78
|
+
attr_reader :catalog
|
79
79
|
class_inheritable_accessor :__config__
|
80
80
|
write_inheritable_attribute(:__config__, Hash.new)
|
81
81
|
|
@@ -97,9 +97,9 @@ module ShadowPuppet
|
|
97
97
|
|
98
98
|
configure(config)
|
99
99
|
@executed = false
|
100
|
-
@
|
101
|
-
|
102
|
-
|
100
|
+
@catalog = Puppet::Resource::Catalog.new
|
101
|
+
@catalog.host_config = false
|
102
|
+
@catalog.name = self.name
|
103
103
|
end
|
104
104
|
|
105
105
|
# Declares that the named method or methods will be called whenever
|
@@ -208,11 +208,7 @@ module ShadowPuppet
|
|
208
208
|
# remove the method rdoc placeholders
|
209
209
|
remove_method(type.name) rescue nil
|
210
210
|
define_method(type.name) do |*args|
|
211
|
-
|
212
|
-
reference(type.name, args.first)
|
213
|
-
else
|
214
|
-
new_resource(type, args.first, args.last)
|
215
|
-
end
|
211
|
+
resource_or_reference(type, *args)
|
216
212
|
end
|
217
213
|
end
|
218
214
|
end
|
@@ -269,9 +265,7 @@ module ShadowPuppet
|
|
269
265
|
def graph_to(name, destination)
|
270
266
|
evaluate_recipes
|
271
267
|
|
272
|
-
|
273
|
-
catalog = bucket.to_catalog
|
274
|
-
relationship_graph = catalog.relationship_graph
|
268
|
+
relationship_graph = @catalog.relationship_graph
|
275
269
|
|
276
270
|
graph = relationship_graph.to_dot_graph("name" => "#{name} Relationships".gsub(/\W+/, '_'))
|
277
271
|
graph.options['label'] = "#{name} Relationships"
|
@@ -294,29 +288,6 @@ module ShadowPuppet
|
|
294
288
|
@executed
|
295
289
|
end
|
296
290
|
|
297
|
-
#An Array of all currently defined resources.
|
298
|
-
def flat_resources
|
299
|
-
a = []
|
300
|
-
@puppet_resources.each_value do |by_type|
|
301
|
-
by_type.each_value do |by_name|
|
302
|
-
a << by_name
|
303
|
-
end
|
304
|
-
end
|
305
|
-
a
|
306
|
-
end
|
307
|
-
|
308
|
-
#A Puppet::TransBucket of all defined resoureces.
|
309
|
-
def export
|
310
|
-
transportable_objects = flat_resources.dup.reject { |a| a.nil? }.flatten.collect do |obj|
|
311
|
-
obj.to_trans
|
312
|
-
end
|
313
|
-
b = Puppet::TransBucket.new(transportable_objects)
|
314
|
-
b.name = name
|
315
|
-
b.type = "class"
|
316
|
-
|
317
|
-
return b
|
318
|
-
end
|
319
|
-
|
320
291
|
private
|
321
292
|
|
322
293
|
#Evaluate the methods calls queued in self.recipes
|
@@ -333,68 +304,46 @@ module ShadowPuppet
|
|
333
304
|
|
334
305
|
# Create a catalog of all contained Puppet Resources and apply that
|
335
306
|
# catalog to the currently running system
|
336
|
-
def apply
|
337
|
-
bucket ||= export()
|
338
|
-
catalog = bucket.to_catalog
|
307
|
+
def apply
|
339
308
|
catalog.apply
|
340
309
|
catalog.clear
|
341
310
|
end
|
342
311
|
|
343
|
-
def
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
312
|
+
def resource_or_reference(type, *args)
|
313
|
+
if args
|
314
|
+
if args.flatten.size == 1
|
315
|
+
reference(type, args.first)
|
316
|
+
elsif resource = existing_resource(type.name, args.first)
|
317
|
+
new_resource(type, args.first, args.last).parameters.each do |name, param|
|
318
|
+
resource[name] = param.value if param.value
|
319
|
+
end
|
320
|
+
resource
|
321
|
+
else
|
322
|
+
add_resource(type, args.first, args.last)
|
353
323
|
end
|
354
|
-
@node.parameters = Facter.to_hash
|
355
|
-
@compile = Puppet::Parser::Compiler.new(@node, @interp.send(:parser, env))
|
356
|
-
@scope = @compile.topscope
|
357
324
|
end
|
358
|
-
@scope
|
359
325
|
end
|
360
326
|
|
361
|
-
|
362
|
-
|
363
|
-
Puppet::Parser::Resource::Reference.new(:type => type.to_s, :title => title.to_s, :scope => scope)
|
327
|
+
def existing_resource(type, title)
|
328
|
+
catalog.resources.detect { |r| r.type == type && r.title == title }
|
364
329
|
end
|
365
330
|
|
366
|
-
#
|
367
|
-
def
|
368
|
-
|
369
|
-
|
370
|
-
:title => name,
|
371
|
-
:type => type.name,
|
372
|
-
:source => self,
|
373
|
-
:scope => scope
|
374
|
-
)
|
375
|
-
@puppet_resources[type][name] = obj
|
376
|
-
end
|
377
|
-
|
378
|
-
case type.name
|
379
|
-
when :exec
|
380
|
-
param = Puppet::Parser::Resource::Param.new(
|
381
|
-
:name => :path,
|
382
|
-
:value => ENV["PATH"],
|
383
|
-
:source => self
|
384
|
-
)
|
385
|
-
obj.send(:set_parameter, param)
|
386
|
-
end
|
331
|
+
# Create a reference to another Puppet Resource.
|
332
|
+
def reference(type, title, params = {})
|
333
|
+
Puppet::Parser::Resource::Reference.new(type.name.to_s.capitalize, title.to_s)
|
334
|
+
end
|
387
335
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
:source => self
|
393
|
-
)
|
394
|
-
obj.send(:set_parameter, param)
|
395
|
-
end
|
336
|
+
# Creates a new Puppet Resource and adds it to the Catalog.
|
337
|
+
def add_resource(type, title, params = {})
|
338
|
+
catalog.add_resource(new_resource(type, title, params))
|
339
|
+
end
|
396
340
|
|
397
|
-
|
341
|
+
def new_resource(type, title, params = {})
|
342
|
+
params.merge!({:title => title.to_s})
|
343
|
+
params.merge!({:catalog => catalog})
|
344
|
+
params.merge!({:path => ENV["PATH"]}) if type.name == :exec && params[:path].nil?
|
345
|
+
params.merge!({:cwd => params[:cwd].to_s}) if params[:cwd]
|
346
|
+
Puppet::Type.type(type.name).new(params)
|
398
347
|
end
|
399
348
|
|
400
349
|
end
|
data/lib/shadow_puppet/test.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
module Puppet
|
2
|
-
|
3
|
-
class Resource
|
2
|
+
class Type
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
undef require
|
4
|
+
# clearing out some puppet methods that we probably won't need for testing
|
5
|
+
# that are also used in the params hash when defining the resource.
|
6
|
+
undef path
|
7
|
+
undef require
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
9
|
+
# This allows access to resource options as methods on the resource.
|
10
|
+
def method_missing name, *args
|
11
|
+
if parameters.keys.include? name.to_sym
|
12
|
+
parameters[name.to_sym].value
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -59,7 +56,9 @@ module ShadowPuppet
|
|
59
56
|
#undefine the method rdoc placeholders
|
60
57
|
undef_method(plural_type) rescue nil
|
61
58
|
define_method(plural_type) do |*args|
|
62
|
-
|
59
|
+
catalog.resources.select { |r| r.type == type.name }.inject({}) do |hash, resource|
|
60
|
+
hash[resource.title] = resource; hash
|
61
|
+
end
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
data/shadow_puppet.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{shadow_puppet}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jesse Newland", "Josh Nichols", "Eric Lindvall", "Lee Jones", "dreamcat4", "Patrick Schless", "Ches Martin", "Rob Lingle", "Scott Fleckenstein"
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = ["Jesse Newland", "Josh Nichols", "Eric Lindvall", "Lee Jones", "Will Farrington", "dreamcat4", "Patrick Schless", "Ches Martin", "Rob Lingle", "Scott Fleckenstein"]
|
12
|
+
s.date = %q{2011-09-20}
|
13
13
|
s.default_executable = %q{shadow_puppet}
|
14
14
|
s.description = %q{A Ruby Puppet DSL}
|
15
|
-
s.email = %q{
|
15
|
+
s.email = %q{will@railsmachine.com}
|
16
16
|
s.executables = ["shadow_puppet"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".gitmodules",
|
23
|
-
"
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
24
26
|
"LICENSE",
|
25
27
|
"README.rdoc",
|
26
28
|
"Rakefile",
|
@@ -31,9 +33,10 @@ Gem::Specification.new do |s|
|
|
31
33
|
"lib/shadow_puppet/manifest.rb",
|
32
34
|
"lib/shadow_puppet/test.rb",
|
33
35
|
"shadow_puppet.gemspec",
|
36
|
+
"spec/cli_spec.rb",
|
37
|
+
"spec/fixtures/cli_spec_manifest.rb",
|
34
38
|
"spec/fixtures/manifests.rb",
|
35
39
|
"spec/manifest_spec.rb",
|
36
|
-
"spec/spec.opts",
|
37
40
|
"spec/spec_helper.rb",
|
38
41
|
"spec/test_spec.rb",
|
39
42
|
"spec/type_spec.rb"
|
@@ -42,37 +45,46 @@ Gem::Specification.new do |s|
|
|
42
45
|
s.rdoc_options = ["--inline-source", "--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/"]
|
43
46
|
s.require_paths = ["lib"]
|
44
47
|
s.rubyforge_project = %q{moonshine}
|
45
|
-
s.rubygems_version = %q{1.
|
48
|
+
s.rubygems_version = %q{1.4.2}
|
46
49
|
s.summary = %q{A Ruby Puppet DSL}
|
47
50
|
|
48
51
|
if s.respond_to? :specification_version then
|
49
52
|
s.specification_version = 3
|
50
53
|
|
51
54
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<puppet>, ["=
|
53
|
-
s.add_runtime_dependency(%q<facter>, [">= 1.5.4"])
|
55
|
+
s.add_runtime_dependency(%q<puppet>, ["= 2.7.3"])
|
54
56
|
s.add_runtime_dependency(%q<highline>, [">= 1.5.0"])
|
55
57
|
s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
|
56
58
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.0.0"])
|
57
|
-
s.
|
58
|
-
s.add_development_dependency(%q<
|
59
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0.5.0"])
|
60
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
61
|
+
s.add_development_dependency(%q<rspec-core>, ["~> 2.6.0"])
|
62
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
63
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
59
65
|
else
|
60
|
-
s.add_dependency(%q<puppet>, ["=
|
61
|
-
s.add_dependency(%q<facter>, [">= 1.5.4"])
|
66
|
+
s.add_dependency(%q<puppet>, ["= 2.7.3"])
|
62
67
|
s.add_dependency(%q<highline>, [">= 1.5.0"])
|
63
68
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
64
69
|
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
65
|
-
s.add_dependency(%q<
|
66
|
-
s.add_dependency(%q<
|
70
|
+
s.add_dependency(%q<i18n>, [">= 0.5.0"])
|
71
|
+
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
72
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.6.0"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
74
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
75
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
67
76
|
end
|
68
77
|
else
|
69
|
-
s.add_dependency(%q<puppet>, ["=
|
70
|
-
s.add_dependency(%q<facter>, [">= 1.5.4"])
|
78
|
+
s.add_dependency(%q<puppet>, ["= 2.7.3"])
|
71
79
|
s.add_dependency(%q<highline>, [">= 1.5.0"])
|
72
80
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
73
81
|
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
74
|
-
s.add_dependency(%q<
|
75
|
-
s.add_dependency(%q<
|
82
|
+
s.add_dependency(%q<i18n>, [">= 0.5.0"])
|
83
|
+
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
84
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.6.0"])
|
85
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
86
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
87
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
76
88
|
end
|
77
89
|
end
|
78
90
|
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "ShadowPuppet's cli" do
|
2
|
+
before(:all) do
|
3
|
+
@root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
4
|
+
@output = `#{@root}/bin/shadow_puppet #{@root}/spec/fixtures/cli_spec_manifest.rb echo=works`
|
5
|
+
end
|
6
|
+
|
7
|
+
it "accepts env variables on the end of the command line" do
|
8
|
+
@output.should =~ /Exec\[from_env\]\/returns: works/
|
9
|
+
end
|
10
|
+
|
11
|
+
it "outputs the name of the manifest it's executing" do
|
12
|
+
pending "can't yet determine how to do this"
|
13
|
+
@output.should =~ /CliSpecManifest/
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/spec/fixtures/manifests.rb
CHANGED
@@ -135,7 +135,54 @@ class TestHelpers < ShadowPuppet::Manifest
|
|
135
135
|
def foo
|
136
136
|
exec('foo', :command => 'true',:onlyif => 'test `hostname` == "foo"')
|
137
137
|
package('bar',:ensure => :installed)
|
138
|
-
file('baz', :content => 'bar',:mode => '644',:owner => 'rails')
|
138
|
+
file('/tmp/baz', :content => 'bar',:mode => '644',:owner => 'rails', :before => package('bar'))
|
139
139
|
end
|
140
140
|
|
141
141
|
end
|
142
|
+
|
143
|
+
class DependencyTestManifest < ShadowPuppet::Manifest
|
144
|
+
def test
|
145
|
+
exec('foobar', :command => 'true', :before => exec('barbaz'))
|
146
|
+
exec('trololol', :command => 'true', :alias => "winning")
|
147
|
+
exec('barbaz', :command => 'true', :require => [exec('foobar'), exec('winning')])
|
148
|
+
|
149
|
+
end
|
150
|
+
recipe :test
|
151
|
+
end
|
152
|
+
|
153
|
+
class StupidTestManifest < ShadowPuppet::Manifest
|
154
|
+
def my_recipe
|
155
|
+
exec 'my_command',
|
156
|
+
:command => 'true',
|
157
|
+
:require => [ file('/tmp/foo'), exec('jk') ]
|
158
|
+
file '/tmp/foo',
|
159
|
+
:content => 'true'
|
160
|
+
exec 'jk',
|
161
|
+
:command => 'true'
|
162
|
+
end
|
163
|
+
recipe :my_recipe
|
164
|
+
end
|
165
|
+
|
166
|
+
class CwdCoercionTest < ShadowPuppet::Manifest
|
167
|
+
def test
|
168
|
+
tmp = Pathname.new('/tmp')
|
169
|
+
exec 'true',
|
170
|
+
:cwd => tmp
|
171
|
+
file tmp + '/foo',
|
172
|
+
:ensure => :present
|
173
|
+
end
|
174
|
+
recipe :test
|
175
|
+
end
|
176
|
+
|
177
|
+
class DuplicateResourceTest < ShadowPuppet::Manifest
|
178
|
+
def first_resource
|
179
|
+
exec 'true',
|
180
|
+
:cwd => Pathname.new('/tmp')
|
181
|
+
end
|
182
|
+
|
183
|
+
def second_resource
|
184
|
+
exec 'true',
|
185
|
+
:cwd => Pathname.new('/tmp'),
|
186
|
+
:logoutput => true
|
187
|
+
end
|
188
|
+
end
|
data/spec/manifest_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
1
|
describe "A manifest" do
|
4
2
|
|
5
3
|
describe "when blank" do
|
@@ -39,7 +37,7 @@ describe "A manifest" do
|
|
39
37
|
end
|
40
38
|
|
41
39
|
it "applies our customizations to resources" do
|
42
|
-
@manifest.execs["foo"].path.should == ENV["PATH"]
|
40
|
+
@manifest.execs["foo"].path.should == ENV["PATH"].split(':')
|
43
41
|
end
|
44
42
|
|
45
43
|
describe "and then executing" do
|
@@ -124,18 +122,14 @@ describe "A manifest" do
|
|
124
122
|
end
|
125
123
|
|
126
124
|
it "creates new resources" do
|
127
|
-
@manifest.should_receive(:
|
128
|
-
@manifest.should_receive(:
|
125
|
+
@manifest.should_receive(:add_resource).with(Puppet::Type::Exec, 'foo', :command => 'true').exactly(1).times
|
126
|
+
@manifest.should_receive(:add_resource).with(Puppet::Type::Exec, 'bar', :command => 'true').exactly(1).times
|
129
127
|
@manifest.send(:evaluate_recipes)
|
130
128
|
end
|
131
129
|
|
132
130
|
it "creates new resources" do
|
133
131
|
@manifest.send(:evaluate_recipes)
|
134
|
-
@manifest.
|
135
|
-
end
|
136
|
-
|
137
|
-
it "can acess a flat array of resources" do
|
138
|
-
@manifest.send(:flat_resources).should == []
|
132
|
+
@manifest.execs.keys.sort.should == ['bar', 'foo']
|
139
133
|
end
|
140
134
|
|
141
135
|
end
|
@@ -221,22 +215,86 @@ describe "A manifest" do
|
|
221
215
|
|
222
216
|
describe "when moonshine setup" do
|
223
217
|
|
218
|
+
before(:each) do
|
219
|
+
@manifest = MoonshineSetupManifest.new
|
220
|
+
end
|
221
|
+
|
222
|
+
it "include directories recipe" do
|
223
|
+
@manifest.class.recipes.map(&:first).should include(:directories)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "calls specified methods" do
|
227
|
+
@manifest.should_receive(:directories)
|
228
|
+
@manifest.send(:evaluate_recipes)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "returns true when executed" do
|
232
|
+
@manifest.execute.should be_true
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "when dependency test manifest" do
|
224
238
|
before(:each) do
|
225
|
-
@manifest =
|
239
|
+
@manifest = DependencyTestManifest.new
|
226
240
|
end
|
227
241
|
|
228
242
|
it "include directories recipe" do
|
229
|
-
@manifest.class.recipes.map(&:first).should include(:
|
243
|
+
@manifest.class.recipes.map(&:first).should include(:test)
|
230
244
|
end
|
231
245
|
|
232
246
|
it "calls specified methods" do
|
233
|
-
@manifest.should_receive(:
|
247
|
+
@manifest.should_receive(:test)
|
234
248
|
@manifest.send(:evaluate_recipes)
|
235
249
|
end
|
236
250
|
|
237
251
|
it "returns true when executed" do
|
238
|
-
@manifest.execute
|
252
|
+
@manifest.execute!.should be_true
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
describe "when referencing files" do
|
257
|
+
before(:each) do
|
258
|
+
@manifest = StupidTestManifest.new
|
259
|
+
end
|
260
|
+
|
261
|
+
it "returns true when executed " do
|
262
|
+
@manifest.execute!.should be_true
|
239
263
|
end
|
264
|
+
end
|
240
265
|
|
266
|
+
describe "when passing a pathname to cwd" do
|
267
|
+
before(:each) do
|
268
|
+
@manifest = CwdCoercionTest.new
|
269
|
+
end
|
270
|
+
|
271
|
+
it "returns true when executed" do
|
272
|
+
@manifest.execute!.should be_true
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "with multiple calls to the same resource" do
|
277
|
+
before(:each) do
|
278
|
+
@manifest = DuplicateResourceTest.new
|
279
|
+
end
|
280
|
+
|
281
|
+
it "creates the resource the first time" do
|
282
|
+
@manifest.first_resource
|
283
|
+
@manifest.execs["true"].cwd.should == '/tmp'
|
284
|
+
@manifest.execs["true"].logoutput.should be_nil
|
285
|
+
end
|
286
|
+
|
287
|
+
it "updates the resource subsequent times" do
|
288
|
+
@manifest.first_resource
|
289
|
+
@manifest.second_resource
|
290
|
+
@manifest.execs["true"].cwd.should == '/tmp'
|
291
|
+
@manifest.execs["true"].logoutput.should be_true
|
292
|
+
end
|
293
|
+
|
294
|
+
it "can execute successfully" do
|
295
|
+
@manifest.first_resource
|
296
|
+
@manifest.second_resource
|
297
|
+
@manifest.execute!
|
298
|
+
end
|
241
299
|
end
|
242
300
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require
|
8
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
5
|
+
$LOAD_PATH.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
6
|
+
|
7
|
+
require 'shadow_puppet/core_ext'
|
8
|
+
require 'shadow_puppet'
|
9
|
+
require 'shadow_puppet/test'
|
10
|
+
|
11
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures', '*.rb')).each do |manifest|
|
9
12
|
require manifest
|
10
13
|
end
|
data/spec/test_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
1
|
describe "ShadowPuppet's test helpers" do
|
4
2
|
|
5
3
|
it "should be created when register_puppet_types_for_testing is called" do
|
@@ -19,24 +17,19 @@ describe "ShadowPuppet's test helpers" do
|
|
19
17
|
end
|
20
18
|
|
21
19
|
it "should allow simple resource lookup" do
|
22
|
-
@manifest.execs.should ==
|
23
|
-
@manifest.packages.should ==
|
24
|
-
@manifest.files.should ==
|
20
|
+
@manifest.execs.keys.should == ['foo']
|
21
|
+
@manifest.packages.keys.should == ['bar']
|
22
|
+
@manifest.files.keys.should == ['/tmp/baz']
|
23
|
+
@manifest.crons.keys.should == []
|
25
24
|
end
|
26
25
|
|
27
26
|
# making sure that properties such as, e.g the :onlyif condition of Exec[foo]
|
28
27
|
# can be accessed simply as manifest.execs['foo'].onlyif rather than via the
|
29
28
|
# param hash
|
30
29
|
it "should allow referencing params directly" do
|
31
|
-
|
32
|
-
@manifest.send(type.to_sym).each do |name,resource|
|
33
|
-
resource.params.keys.each do |param|
|
34
|
-
resource.send(param.to_sym).should == resource.params[param.to_sym].value
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
30
|
+
@manifest.execs['foo'].command.should == 'true'
|
38
31
|
end
|
39
32
|
|
40
33
|
end
|
41
34
|
|
42
|
-
end
|
35
|
+
end
|
data/spec/type_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
1
|
describe "ShadowPuppet's type loading mechanism" do
|
4
2
|
it "should create a new type helper methods when register_puppet_types is called" do
|
5
3
|
Puppet::Type.newtype(:dummy_1){ }
|
@@ -9,4 +7,4 @@ describe "ShadowPuppet's type loading mechanism" do
|
|
9
7
|
ShadowPuppet::Manifest.register_puppet_types
|
10
8
|
BlankManifest.new.respond_to?(:dummy_1).should == true
|
11
9
|
end
|
12
|
-
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,68 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shadow_puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jesse Newland
|
14
14
|
- Josh Nichols
|
15
15
|
- Eric Lindvall
|
16
16
|
- Lee Jones
|
17
|
+
- Will Farrington
|
17
18
|
- dreamcat4
|
18
19
|
- Patrick Schless
|
19
20
|
- Ches Martin
|
20
21
|
- Rob Lingle
|
21
22
|
- Scott Fleckenstein
|
22
|
-
- Will Farrington
|
23
23
|
autorequire:
|
24
24
|
bindir: bin
|
25
25
|
cert_chain: []
|
26
26
|
|
27
|
-
date: 2011-
|
27
|
+
date: 2011-09-20 00:00:00 -04:00
|
28
28
|
default_executable: shadow_puppet
|
29
29
|
dependencies:
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
+
type: :runtime
|
31
32
|
name: puppet
|
32
|
-
|
33
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
33
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
36
|
- - "="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
hash:
|
38
|
+
hash: 21
|
39
39
|
segments:
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
version:
|
44
|
-
type: :runtime
|
45
|
-
version_requirements: *id001
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: facter
|
40
|
+
- 2
|
41
|
+
- 7
|
42
|
+
- 3
|
43
|
+
version: 2.7.3
|
48
44
|
prerelease: false
|
49
|
-
requirement:
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
hash: 11
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 5
|
58
|
-
- 4
|
59
|
-
version: 1.5.4
|
60
|
-
type: :runtime
|
61
|
-
version_requirements: *id002
|
45
|
+
requirement: *id001
|
62
46
|
- !ruby/object:Gem::Dependency
|
47
|
+
type: :runtime
|
63
48
|
name: highline
|
64
|
-
|
65
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
66
50
|
none: false
|
67
51
|
requirements:
|
68
52
|
- - ">="
|
@@ -73,12 +57,12 @@ dependencies:
|
|
73
57
|
- 5
|
74
58
|
- 0
|
75
59
|
version: 1.5.0
|
76
|
-
|
77
|
-
|
60
|
+
prerelease: false
|
61
|
+
requirement: *id002
|
78
62
|
- !ruby/object:Gem::Dependency
|
63
|
+
type: :runtime
|
79
64
|
name: builder
|
80
|
-
|
81
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
82
66
|
none: false
|
83
67
|
requirements:
|
84
68
|
- - ">="
|
@@ -89,12 +73,12 @@ dependencies:
|
|
89
73
|
- 1
|
90
74
|
- 2
|
91
75
|
version: 2.1.2
|
92
|
-
|
93
|
-
|
76
|
+
prerelease: false
|
77
|
+
requirement: *id003
|
94
78
|
- !ruby/object:Gem::Dependency
|
79
|
+
type: :runtime
|
95
80
|
name: activesupport
|
96
|
-
|
97
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
98
82
|
none: false
|
99
83
|
requirements:
|
100
84
|
- - ">="
|
@@ -105,12 +89,76 @@ dependencies:
|
|
105
89
|
- 0
|
106
90
|
- 0
|
107
91
|
version: 2.0.0
|
92
|
+
prerelease: false
|
93
|
+
requirement: *id004
|
94
|
+
- !ruby/object:Gem::Dependency
|
108
95
|
type: :runtime
|
109
|
-
|
96
|
+
name: i18n
|
97
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 11
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
- 5
|
106
|
+
- 0
|
107
|
+
version: 0.5.0
|
108
|
+
prerelease: false
|
109
|
+
requirement: *id005
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
+
type: :development
|
111
112
|
name: rspec
|
113
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
hash: 23
|
119
|
+
segments:
|
120
|
+
- 2
|
121
|
+
- 6
|
122
|
+
- 0
|
123
|
+
version: 2.6.0
|
124
|
+
prerelease: false
|
125
|
+
requirement: *id006
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
type: :development
|
128
|
+
name: rspec-core
|
129
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ~>
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 23
|
135
|
+
segments:
|
136
|
+
- 2
|
137
|
+
- 6
|
138
|
+
- 0
|
139
|
+
version: 2.6.0
|
112
140
|
prerelease: false
|
113
|
-
requirement:
|
141
|
+
requirement: *id007
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
type: :development
|
144
|
+
name: jeweler
|
145
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ~>
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 11
|
151
|
+
segments:
|
152
|
+
- 1
|
153
|
+
- 6
|
154
|
+
- 2
|
155
|
+
version: 1.6.2
|
156
|
+
prerelease: false
|
157
|
+
requirement: *id008
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
type: :development
|
160
|
+
name: ruby-debug
|
161
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
114
162
|
none: false
|
115
163
|
requirements:
|
116
164
|
- - ">="
|
@@ -119,12 +167,12 @@ dependencies:
|
|
119
167
|
segments:
|
120
168
|
- 0
|
121
169
|
version: "0"
|
122
|
-
type: :development
|
123
|
-
version_requirements: *id006
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: isolate-scenarios
|
126
170
|
prerelease: false
|
127
|
-
requirement:
|
171
|
+
requirement: *id009
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
type: :development
|
174
|
+
name: ruby-debug19
|
175
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
128
176
|
none: false
|
129
177
|
requirements:
|
130
178
|
- - ">="
|
@@ -133,10 +181,10 @@ dependencies:
|
|
133
181
|
segments:
|
134
182
|
- 0
|
135
183
|
version: "0"
|
136
|
-
|
137
|
-
|
184
|
+
prerelease: false
|
185
|
+
requirement: *id010
|
138
186
|
description: A Ruby Puppet DSL
|
139
|
-
email:
|
187
|
+
email: will@railsmachine.com
|
140
188
|
executables:
|
141
189
|
- shadow_puppet
|
142
190
|
extensions: []
|
@@ -146,7 +194,9 @@ extra_rdoc_files:
|
|
146
194
|
- README.rdoc
|
147
195
|
files:
|
148
196
|
- .gitmodules
|
149
|
-
-
|
197
|
+
- .rspec
|
198
|
+
- Gemfile
|
199
|
+
- Gemfile.lock
|
150
200
|
- LICENSE
|
151
201
|
- README.rdoc
|
152
202
|
- Rakefile
|
@@ -157,9 +207,10 @@ files:
|
|
157
207
|
- lib/shadow_puppet/manifest.rb
|
158
208
|
- lib/shadow_puppet/test.rb
|
159
209
|
- shadow_puppet.gemspec
|
210
|
+
- spec/cli_spec.rb
|
211
|
+
- spec/fixtures/cli_spec_manifest.rb
|
160
212
|
- spec/fixtures/manifests.rb
|
161
213
|
- spec/manifest_spec.rb
|
162
|
-
- spec/spec.opts
|
163
214
|
- spec/spec_helper.rb
|
164
215
|
- spec/test_spec.rb
|
165
216
|
- spec/type_spec.rb
|
@@ -194,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
245
|
requirements: []
|
195
246
|
|
196
247
|
rubyforge_project: moonshine
|
197
|
-
rubygems_version: 1.
|
248
|
+
rubygems_version: 1.4.2
|
198
249
|
signing_key:
|
199
250
|
specification_version: 3
|
200
251
|
summary: A Ruby Puppet DSL
|
data/IsolateScenarios
DELETED
data/spec/spec.opts
DELETED