nullstyle-shadow_puppet 0.1.17

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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.rdoc ADDED
@@ -0,0 +1,11 @@
1
+ = ShadowPuppet
2
+
3
+ ShadowPuppet is a Ruby DSL for Puppet, extracted out of the work we at Rails
4
+ Machine are doing on Moonshine[http://blog.railsmachine.com/articles/2009/01/16/moonshine-configuration-management-and-deployment/].
5
+
6
+ ShadowPuppet provides a DSL for creating collections ("manifests") of Puppet
7
+ Resources in Ruby. For documentation on writing these manifests, please see
8
+ ShadowPuppet::Manifest.
9
+
10
+ A binary[http://railsmachine.github.com/shadow_puppet/files/bin/shadow_puppet.html] is provided to parse and execute a
11
+ ShadowPuppet::Manifest.
data/bin/shadow_puppet ADDED
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+ #== Sample manifest:
3
+ #
4
+ # $ cat examples/foo.rb
5
+ # class Foo < ShadowPuppet::Manifest
6
+ # recipe :demo, :text => 'foo'
7
+ # recipe :some_gems
8
+ #
9
+ # def some_gems
10
+ # package 'rails', :ensure => :updated, :provider => :gem
11
+ # package 'railsmachine', :ensure => '1.0.5', :provider => :gem, :require => package('capistrano')
12
+ # package 'capistrano', :ensure => :updated, :provider => :gem
13
+ # end
14
+ #
15
+ # def demo(options = {})
16
+ # exec 'sample', :command => "echo '#{options[:text]}' > /tmp/sample.txt"
17
+ # file '/tmp/sample2.txt', :ensure => :present, :content => Facter.to_hash.inspect
18
+ # end
19
+ # end
20
+ #
21
+ #== Executing this manifest:
22
+ #
23
+ # $ shadow_puppet examples/foo.rb
24
+ # notice: /shadow_puppet:19861340/Exec[foo]/returns: executed successfully
25
+ # $
26
+ #
27
+ #The shadow_puppet binary parses the given ruby code, which is
28
+ #expected to contain a class named Foo that inherits from
29
+ #ShadowPuppet::Manifest. An instance of this class is created, and the
30
+ #<tt>execute</tt> method is called. All output is printed to the console.
31
+
32
+ begin
33
+
34
+ require 'optparse'
35
+ opts = OptionParser.new do |opts|
36
+ opts.banner = <<-EOF
37
+ NAME
38
+ Shadow Puppet
39
+
40
+ AUTHOR
41
+ Jesse Newland
42
+ jesse@railsmachine.com
43
+
44
+ DESCRIPTION
45
+ A Ruby DSL for puppet
46
+
47
+ EXAMPLES
48
+ Sample manifest:
49
+
50
+ #foo.rb
51
+ class Foo < ShadowPuppet::Manifest
52
+ recipe :foo
53
+
54
+ def foo
55
+ exec :foo, :command => 'echo "foo" > /tmp/foo.txt'
56
+ file '/tmp/example.txt', :ensure => :present, :content => Facter.to_hash.inspect
57
+ end
58
+ end
59
+
60
+ Executing this manifest:
61
+
62
+ $ shadow_puppet foo.rb
63
+ notice: /shadow_puppet:19861340/Exec[foo]/returns: executed successfully
64
+ $
65
+
66
+ The shadow_puppet binary parses the given ruby code, which is
67
+ expected to contain a class named Foo that inherits from
68
+ ShadowPuppet::Manifest. An instance of this class is created, and the
69
+ execute method is called. All output is printed to the console.
70
+ EOF
71
+
72
+ end
73
+
74
+ opts.parse!
75
+
76
+ require 'rubygems'
77
+ require 'shadow_puppet'
78
+ require 'active_support/inflector'
79
+ require 'active_support/core_ext/string/inflections'
80
+ unless String.included_modules.include?(ActiveSupport::CoreExtensions::String::Inflections)
81
+ String.send :include, ActiveSupport::CoreExtensions::String::Inflections
82
+ end
83
+ require 'fileutils'
84
+
85
+ filename = ARGV[0]
86
+ raise ArgumentError unless filename
87
+
88
+ klass = File.basename(filename, ".rb")
89
+ require filename
90
+ manifest = klass.classify.constantize.new
91
+ manifest.execute! && exit(0)
92
+ rescue Errno::EACCES
93
+ puts "Please run shadow_puppet as root"
94
+ rescue Exception => e
95
+ if e.instance_of?(SystemExit)
96
+ raise
97
+ else
98
+ puts 'Uncaught exception'
99
+ puts e.class
100
+ puts e.message
101
+ puts e.backtrace.join("\n")
102
+ exit(1)
103
+ end
104
+ end
data/examples/foo.rb ADDED
@@ -0,0 +1,15 @@
1
+ class Foo < ShadowPuppet::Manifest
2
+ recipe :demo, :text => 'foo'
3
+ recipe :some_gems
4
+
5
+ def some_gems
6
+ package 'rails', :ensure => :updated, :provider => :gem
7
+ package 'railsmachine', :ensure => '1.0.5', :provider => :gem, :require => package('capistrano')
8
+ package 'capistrano', :ensure => :updated, :provider => :gem
9
+ end
10
+
11
+ def demo(options = {})
12
+ exec 'sample', :command => "echo '#{options[:text]}' > /tmp/sample.txt"
13
+ file '/tmp/sample2.txt', :ensure => :present, :content => Facter.to_hash.inspect
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ require 'active_support/core_ext/class/attribute_accessors'
2
+ require 'active_support/core_ext/array'
3
+ require 'active_support/inflector'
4
+ require 'active_support/core_ext/class/inheritable_attributes'
5
+ require 'active_support/core_ext/duplicable'
6
+ class Configatron::Store
7
+ def to_s
8
+ ''
9
+ end
10
+ end
@@ -0,0 +1,367 @@
1
+ module ShadowPuppet
2
+ # A Manifest is an executable collection of Puppet Resources[http://reductivelabs.com/trac/puppet/wiki/TypeReference].
3
+ #
4
+ # ===Example
5
+ #
6
+ # class ManifestExample < ShadowPuppet::Manifest
7
+ # recipe :sample
8
+ # recipe :lamp, :ruby # queue calls to self.lamp and
9
+ # # self.ruby when executing
10
+ #
11
+ # recipe :mysql, { # queue a call to self.mysql
12
+ # :root_password => 'OMGSEKRET' # passing the provided hash
13
+ # } # as an option
14
+ #
15
+ # def sample
16
+ # exec :foo, :command => 'echo "foo" > /tmp/foo.txt'
17
+ #
18
+ # package :foo, :ensure => :installed
19
+ #
20
+ # file '/tmp/example.txt',
21
+ # :ensure => :present,
22
+ # :contents => Facter.to_hash_inspect,
23
+ # :require => package(:foo)
24
+ # end
25
+ #
26
+ # def lamp
27
+ # #install a basic LAMP stack
28
+ # end
29
+ #
30
+ # def ruby
31
+ # #install a ruby interpreter and tools
32
+ # end
33
+ #
34
+ # def mysql(options)
35
+ # #install a mysql server and set the root password to options[:root_password]
36
+ # end
37
+ #
38
+ # end
39
+ #
40
+ # To execute the above manifest, instantiate it and call execute on it:
41
+ #
42
+ # m = ManifestExample.new
43
+ # m.execute
44
+ #
45
+ # As shown in the +sample+ method in ManifestExample above, instance
46
+ # methods are created for each Puppet::Type available on your system. These
47
+ # methods behave identally to the Puppet Resources methods. See here[http://reductivelabs.com/trac/puppet/wiki/TypeReference]
48
+ # for documentation on these methods.
49
+ #
50
+ # To view a list of all defined methods on your system, run:
51
+ #
52
+ # ruby -rubygems -e 'require "shadow_puppet";puts ShadowPuppet::Manifest.puppet_type_methods'
53
+ #
54
+ # The use of methods (+sample+, +lamp+, +ruby+, and +mysql+ above) as a
55
+ # container for resources facilitates recipie re-use through the use of Ruby
56
+ # Modules. For example:
57
+ #
58
+ # module ApachePuppet
59
+ # # Required options:
60
+ # # domain
61
+ # # path
62
+ # def php_vhost(options)
63
+ # #...
64
+ # end
65
+ # end
66
+ #
67
+ # class MyWebMainfest < ShadowPuppet::Manifest
68
+ # include ApachePuppet
69
+ # recipe :php_vhost, {
70
+ # :domain => 'foo.com',
71
+ # :path => '/var/www/apps/foo'
72
+ # }
73
+ # end
74
+ class Manifest
75
+
76
+ class_inheritable_accessor :recipes
77
+ write_inheritable_attribute(:recipes, [])
78
+ attr_reader :puppet_resources
79
+ class_inheritable_accessor :__configatron__
80
+ write_inheritable_attribute(:__configatron__, Configatron::Store.new)
81
+
82
+ # Initialize a new instance of this manifest. This can take a
83
+ # config hash, which is immediately passed on to the configure
84
+ # method
85
+ def initialize(config = {})
86
+ if Process.uid == 0
87
+ Puppet[:confdir] = File.expand_path("/etc/shadow_puppet")
88
+ Puppet[:vardir] = File.expand_path("/var/shadow_puppet")
89
+ else
90
+ Puppet[:confdir] = File.expand_path("~/.shadow_puppet")
91
+ Puppet[:vardir] = File.expand_path("~/.shadow_puppet/var")
92
+ end
93
+ Puppet[:user] = Process.uid
94
+ Puppet[:group] = Process.gid
95
+ Puppet::Util::Log.newdestination(:console)
96
+
97
+ configure(config)
98
+ @executed = false
99
+ @puppet_resources = Hash.new do |hash, key|
100
+ hash[key] = {}
101
+ end
102
+ end
103
+
104
+ # Declares that the named method or methods will be called whenever
105
+ # execute is called on an instance of this class. If the last argument is
106
+ # a Hash, this hash is passed as an argument to all provided methods.
107
+ # If no options hash is provided, each method is passed the contents of
108
+ # <tt>configuration[method]</tt>.
109
+ #
110
+ # Subclasses of the Manifest class properly inherit the parent classes'
111
+ # calls to recipe.
112
+ def self.recipe(*methods)
113
+ return nil if methods.nil? || methods == []
114
+ options = methods.extract_options!
115
+ methods.each do |meth|
116
+ # options = configatron.send(meth.to_sym) if options == {}
117
+ options ||= {}
118
+ recipes << [meth.to_sym, options]
119
+ end
120
+ end
121
+
122
+ def self.configatron
123
+ __configatron__
124
+ end
125
+
126
+ def configatron
127
+ self.class.__configatron__
128
+ end
129
+
130
+ # A hash describing any configuration that has been
131
+ # performed on the class. Modify this hash by calling configure:
132
+ #
133
+ # class SampleManifest < ShadowPuppet::Manifest
134
+ # configure(:name => 'test')
135
+ # end
136
+ #
137
+ # >> SampleManifest.configuration
138
+ # => {"name" => 'test'}
139
+ #
140
+ # Subclasses of the Manifest class properly inherit the parent classes'
141
+ # configuration.
142
+ def self.configuration
143
+ configatron.to_hash
144
+ end
145
+
146
+ # Access to the configuration of the creating class.
147
+ def configuration
148
+ self.class.configuration
149
+ end
150
+
151
+ # Define configuration on this manifest. This is useful for storing things
152
+ # such as hostnames, password, or usernames that may change between
153
+ # different implementations of a shared manifest. Access this hash by
154
+ # calling configuration:
155
+ #
156
+ # class SampleManifest < ShadowPuppet::Manifest
157
+ # configure(:name => 'test')
158
+ # end
159
+ #
160
+ # >> SampleManifest.configuration
161
+ # => {"name" => 'test'}
162
+ #
163
+ # Subsequent calls to configure perform a deep_merge of the
164
+ # provided <tt>hash</tt> into the pre-existing configuration
165
+ def self.configure(hash)
166
+ __configatron__.configure_from_hash(hash)
167
+ end
168
+
169
+ # Define configuration on this manifest's creating class. This is useful
170
+ # for storing things such as hostnames, password, or usernames that may
171
+ # change between different implementations of a shared manifest.
172
+ def configure(hash)
173
+ self.class.configure(hash)
174
+ end
175
+ alias_method :configuration=, :configure
176
+
177
+ #An array of all methods defined for creation of Puppet Resources
178
+ def self.puppet_type_methods
179
+ Puppet::Type.eachtype { |t| t.name }.keys.map { |n| n.to_s }.sort.inspect
180
+ end
181
+
182
+ def name
183
+ @name ||= "#{self.class}##{self.object_id}"
184
+ end
185
+
186
+ #Create an instance method for every type that either creates or references
187
+ #a resource
188
+ def self.register_puppet_types
189
+ Puppet::Type.loadall
190
+ Puppet::Type.eachtype do |type|
191
+ #undefine the method rdoc placeholders
192
+ undef_method(type.name) rescue nil
193
+ define_method(type.name) do |*args|
194
+ if args && args.flatten.size == 1
195
+ reference(type.name, args.first)
196
+ else
197
+ new_resource(type, args.first, args.last)
198
+ end
199
+ end
200
+ end
201
+ end
202
+ register_puppet_types
203
+
204
+ # Returns true if this Manifest <tt>respond_to?</tt> all methods named by
205
+ # calls to recipe, and if this Manifest has not been executed before.
206
+ def executable?
207
+ self.class.recipes.each do |meth,args|
208
+ return false unless respond_to?(meth)
209
+ end
210
+ return false if executed?
211
+ true
212
+ end
213
+
214
+ def missing_recipes
215
+ missing = self.class.recipes.each do |meth,args|
216
+ !respond_to?(meth)
217
+ end
218
+ end
219
+
220
+ # Execute this manifest, applying all resources defined. Execute returns
221
+ # true if successfull, and false if unsucessfull. By default, this
222
+ # will only execute a manifest that has not already been executed?.
223
+ # The +force+ argument, if true, removes this check.
224
+ def execute(force=false)
225
+ return false if executed? && !force
226
+ evaluate_recipes
227
+ apply
228
+ rescue Exception => e
229
+ false
230
+ else
231
+ true
232
+ ensure
233
+ @executed = true
234
+ end
235
+
236
+ # Execute this manifest, applying all resources defined. Execute returns
237
+ # true if successfull, and raises an exception if not. By default, this
238
+ # will only execute a manifest that has not already been executed?.
239
+ # The +force+ argument, if true, removes this check.
240
+ def execute!(force=false)
241
+ return false if executed? && !force
242
+ evaluate_recipes
243
+ apply
244
+ rescue Exception => e
245
+ raise e
246
+ else
247
+ true
248
+ ensure
249
+ @executed = true
250
+ end
251
+
252
+ protected
253
+
254
+ #Has this manifest instance been executed?
255
+ def executed?
256
+ @executed
257
+ end
258
+
259
+ #An Array of all currently defined resources.
260
+ def flat_resources
261
+ a = []
262
+ @puppet_resources.each_value do |by_type|
263
+ by_type.each_value do |by_name|
264
+ a << by_name
265
+ end
266
+ end
267
+ a
268
+ end
269
+
270
+ #A Puppet::TransBucket of all defined resoureces.
271
+ def export
272
+ transportable_objects = flat_resources.dup.reject { |a| a.nil? }.flatten.collect do |obj|
273
+ obj.to_trans
274
+ end
275
+ b = Puppet::TransBucket.new(transportable_objects)
276
+ b.name = name
277
+ b.type = "class"
278
+
279
+ return b
280
+ end
281
+
282
+ private
283
+
284
+ #Evaluate the methods calls queued in self.recipes
285
+ def evaluate_recipes
286
+ self.class.recipes.each do |meth, args|
287
+ case arity = method(meth).arity
288
+ when 1, -1
289
+ send(meth, args)
290
+ else
291
+ send(meth)
292
+ end
293
+ end
294
+ end
295
+
296
+ # Create a catalog of all contained Puppet Resources and apply that
297
+ # catalog to the currently running system
298
+ def apply(bucket = nil)
299
+ bucket ||= export()
300
+ catalog = bucket.to_catalog
301
+ catalog.apply
302
+ catalog.clear
303
+ end
304
+
305
+ def scope #:nodoc:
306
+ unless defined?(@scope)
307
+ # Set the code to something innocuous; we just need the
308
+ # scopes, not the interpreter. Hackish, but true.
309
+ Puppet[:code] = " "
310
+ @interp = Puppet::Parser::Interpreter.new
311
+ require 'puppet/node'
312
+ @node = Puppet::Node.new(Facter.value(:hostname))
313
+ if env = Puppet[:environment] and env == ""
314
+ env = nil
315
+ end
316
+ @node.parameters = Facter.to_hash
317
+ @compile = Puppet::Parser::Compiler.new(@node, @interp.send(:parser, env))
318
+ @scope = @compile.topscope
319
+ end
320
+ @scope
321
+ end
322
+
323
+ #Create a reference to another Puppet Resource.
324
+ def reference(type, title)
325
+ Puppet::Parser::Resource::Reference.new(:type => type.to_s, :title => title.to_s, :scope => scope)
326
+ end
327
+
328
+ #Creates a new Puppet Resource.
329
+ def new_resource(type, name, params = {})
330
+ unless obj = @puppet_resources[type][name]
331
+ obj = Puppet::Parser::Resource.new(
332
+ :title => name,
333
+ :type => type.name,
334
+ :source => self,
335
+ :scope => scope
336
+ )
337
+ @puppet_resources[type][name] = obj
338
+ end
339
+
340
+ case type.name
341
+ when :exec
342
+ param = Puppet::Parser::Resource::Param.new(
343
+ :name => :path,
344
+ :value => ENV["PATH"],
345
+ :source => self
346
+ )
347
+ obj.send(:set_parameter, param)
348
+ end
349
+
350
+ params.each do |param_name, param_value|
351
+ param = Puppet::Parser::Resource::Param.new(
352
+ :name => param_name,
353
+ :value => param_value,
354
+ :source => self
355
+ )
356
+ obj.send(:set_parameter, param)
357
+ end
358
+
359
+ obj
360
+ end
361
+
362
+ end
363
+ end
364
+
365
+ Dir.glob(File.join(File.dirname(__FILE__), '..', 'facts', '*.rb')).each do |fact|
366
+ require fact
367
+ end
@@ -0,0 +1,31 @@
1
+ require 'puppet'
2
+ require 'configatron'
3
+ require 'erb'
4
+ require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'core_ext.rb')
5
+ require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'manifest.rb')
6
+
7
+ class ShadowPuppet::Manifest::Setup < ShadowPuppet::Manifest
8
+ recipe :setup_directories
9
+
10
+ def setup_directories()
11
+ if Process.uid == 0
12
+ file "/var/shadow_puppet",
13
+ :ensure => "directory",
14
+ :backup => false
15
+ file "/etc/shadow_puppet",
16
+ :ensure => "directory",
17
+ :backup => false
18
+ else
19
+ file ENV["HOME"] + "/.shadow_puppet",
20
+ :ensure => "directory",
21
+ :backup => false
22
+ file ENV["HOME"] + "/.shadow_puppet/var",
23
+ :ensure => "directory",
24
+ :backup => false,
25
+ :require => file(ENV["HOME"] + "/.shadow_puppet")
26
+ end
27
+ end
28
+ end
29
+
30
+ setup = ShadowPuppet::Manifest::Setup.new
31
+ setup.execute
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nullstyle-shadow_puppet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.17
5
+ platform: ruby
6
+ authors:
7
+ - Jesse Newland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-06 00:00:00 -08:00
13
+ default_executable: shadow_puppet
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: puppet
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.24.6
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: facter
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.4
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: highline
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: builder
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.1.2
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.0.0
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: configatron
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.2.2
74
+ version:
75
+ description: A Ruby Puppet DSL
76
+ email:
77
+ - jesse@railsmachine.com
78
+ executables:
79
+ - shadow_puppet
80
+ extensions: []
81
+
82
+ extra_rdoc_files:
83
+ - README.rdoc
84
+ - bin/shadow_puppet
85
+ files:
86
+ - README.rdoc
87
+ - LICENSE
88
+ - bin/shadow_puppet
89
+ - examples/foo.rb
90
+ - lib/shadow_puppet.rb
91
+ - lib/shadow_puppet/manifest.rb
92
+ - lib/shadow_puppet/core_ext.rb
93
+ has_rdoc: true
94
+ homepage: http://railsmachine.github.com/shadow_puppet
95
+ post_install_message:
96
+ rdoc_options:
97
+ - --main
98
+ - README.rdoc
99
+ - --inline-source
100
+ - --webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ requirements: []
116
+
117
+ rubyforge_project: moonshine
118
+ rubygems_version: 1.2.0
119
+ signing_key:
120
+ specification_version: 2
121
+ summary: A Ruby Puppet DSL
122
+ test_files: []
123
+