railsmachine-shadow_puppet 0.1.16 → 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/bin/shadow_puppet +1 -2
- data/lib/shadow_puppet/core_ext.rb +8 -1
- data/lib/shadow_puppet/manifest.rb +38 -5
- metadata +1 -1
data/bin/shadow_puppet
CHANGED
@@ -88,8 +88,7 @@ begin
|
|
88
88
|
klass = File.basename(filename, ".rb")
|
89
89
|
require filename
|
90
90
|
manifest = klass.classify.constantize.new
|
91
|
-
execute
|
92
|
-
execute ? exit(0) : exit(1)
|
91
|
+
manifest.execute! && exit(0)
|
93
92
|
rescue Errno::EACCES
|
94
93
|
puts "Please run shadow_puppet as root"
|
95
94
|
rescue Exception => e
|
@@ -1,3 +1,10 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute_accessors'
|
2
2
|
require 'active_support/core_ext/array'
|
3
|
-
require 'active_support/inflector'
|
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
|
@@ -76,6 +76,8 @@ module ShadowPuppet
|
|
76
76
|
class_inheritable_accessor :recipes
|
77
77
|
write_inheritable_attribute(:recipes, [])
|
78
78
|
attr_reader :puppet_resources
|
79
|
+
class_inheritable_accessor :__configatron__
|
80
|
+
write_inheritable_attribute(:__configatron__, Configatron::Store.new)
|
79
81
|
|
80
82
|
# Initialize a new instance of this manifest. This can take a
|
81
83
|
# config hash, which is immediately passed on to the configure
|
@@ -117,6 +119,14 @@ module ShadowPuppet
|
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
122
|
+
def self.configatron
|
123
|
+
__configatron__
|
124
|
+
end
|
125
|
+
|
126
|
+
def configatron
|
127
|
+
self.class.__configatron__
|
128
|
+
end
|
129
|
+
|
120
130
|
# A hash describing any configuration that has been
|
121
131
|
# performed on the class. Modify this hash by calling configure:
|
122
132
|
#
|
@@ -153,7 +163,7 @@ module ShadowPuppet
|
|
153
163
|
# Subsequent calls to configure perform a deep_merge of the
|
154
164
|
# provided <tt>hash</tt> into the pre-existing configuration
|
155
165
|
def self.configure(hash)
|
156
|
-
|
166
|
+
__configatron__.configure_from_hash(hash)
|
157
167
|
end
|
158
168
|
|
159
169
|
# Define configuration on this manifest's creating class. This is useful
|
@@ -201,11 +211,34 @@ module ShadowPuppet
|
|
201
211
|
true
|
202
212
|
end
|
203
213
|
|
204
|
-
|
205
|
-
|
206
|
-
|
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.
|
207
224
|
def execute(force=false)
|
208
|
-
return 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
|
209
242
|
evaluate_recipes
|
210
243
|
apply
|
211
244
|
rescue Exception => e
|