puppet 0.25.0 → 0.25.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (138) hide show
  1. data/CHANGELOG +4772 -19114
  2. data/README +1 -1
  3. data/Rakefile +7 -25
  4. data/{sbin → bin}/puppetca +0 -0
  5. data/{sbin → bin}/puppetd +0 -0
  6. data/{sbin → bin}/puppetmasterd +0 -0
  7. data/{sbin → bin}/puppetqd +0 -0
  8. data/{sbin → bin}/puppetrun +0 -0
  9. data/conf/osx/createpackage.sh +1 -1
  10. data/conf/redhat/client.init +6 -3
  11. data/conf/redhat/puppet.spec +26 -14
  12. data/conf/redhat/server.init +3 -2
  13. data/ext/vim/syntax/puppet.vim +4 -1
  14. data/install.rb +25 -7
  15. data/lib/puppet.rb +1 -1
  16. data/lib/puppet/agent.rb +2 -2
  17. data/lib/puppet/application/puppet.rb +3 -3
  18. data/lib/puppet/application/puppetd.rb +0 -7
  19. data/lib/puppet/application/puppetdoc.rb +1 -0
  20. data/lib/puppet/application/puppetmasterd.rb +2 -2
  21. data/lib/puppet/configurer.rb +6 -1
  22. data/lib/puppet/configurer/fact_handler.rb +2 -2
  23. data/lib/puppet/defaults.rb +2 -2
  24. data/lib/puppet/external/nagios/base.rb +4 -3
  25. data/lib/puppet/external/pson/common.rb +367 -0
  26. data/lib/puppet/external/pson/pure.rb +77 -0
  27. data/lib/puppet/external/pson/pure/generator.rb +429 -0
  28. data/lib/puppet/external/pson/pure/parser.rb +269 -0
  29. data/lib/puppet/external/pson/version.rb +8 -0
  30. data/lib/puppet/feature/pson.rb +6 -0
  31. data/lib/puppet/feature/rails.rb +1 -5
  32. data/lib/puppet/file_serving/configuration.rb +2 -2
  33. data/lib/puppet/indirector/certificate/rest.rb +6 -0
  34. data/lib/puppet/indirector/facts/facter.rb +1 -1
  35. data/lib/puppet/indirector/ldap.rb +1 -1
  36. data/lib/puppet/indirector/queue.rb +3 -3
  37. data/lib/puppet/indirector/rest.rb +1 -1
  38. data/lib/puppet/network/authstore.rb +34 -53
  39. data/lib/puppet/network/formats.rb +59 -9
  40. data/lib/puppet/network/http/mongrel/rest.rb +10 -9
  41. data/lib/puppet/network/http/webrick.rb +8 -1
  42. data/lib/puppet/network/http/webrick/rest.rb +2 -5
  43. data/lib/puppet/network/http_server/webrick.rb +1 -4
  44. data/lib/puppet/parser/ast/leaf.rb +1 -3
  45. data/lib/puppet/parser/collector.rb +14 -8
  46. data/lib/puppet/parser/compiler.rb +7 -0
  47. data/lib/puppet/parser/functions/fqdn_rand.rb +4 -10
  48. data/lib/puppet/parser/functions/regsubst.rb +44 -30
  49. data/lib/puppet/parser/functions/require.rb +18 -3
  50. data/lib/puppet/parser/functions/versioncmp.rb +1 -1
  51. data/lib/puppet/parser/interpreter.rb +1 -1
  52. data/lib/puppet/parser/lexer.rb +29 -31
  53. data/lib/puppet/parser/loaded_code.rb +4 -0
  54. data/lib/puppet/parser/parser_support.rb +5 -2
  55. data/lib/puppet/parser/resource.rb +31 -6
  56. data/lib/puppet/property.rb +3 -2
  57. data/lib/puppet/provider/macauthorization/macauthorization.rb +14 -14
  58. data/lib/puppet/provider/package/dpkg.rb +1 -1
  59. data/lib/puppet/provider/package/portage.rb +15 -5
  60. data/lib/puppet/provider/package/rug.rb +1 -1
  61. data/lib/puppet/provider/package/up2date.rb +1 -1
  62. data/lib/puppet/provider/package/urpmi.rb +1 -1
  63. data/lib/puppet/provider/service/daemontools.rb +7 -10
  64. data/lib/puppet/provider/service/runit.rb +7 -17
  65. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -47
  66. data/lib/puppet/provider/zone/solaris.rb +12 -3
  67. data/lib/puppet/relationship.rb +12 -12
  68. data/lib/puppet/reports/rrdgraph.rb +1 -1
  69. data/lib/puppet/reports/store.rb +2 -2
  70. data/lib/puppet/reports/tagmail.rb +5 -16
  71. data/lib/puppet/resource.rb +15 -20
  72. data/lib/puppet/resource/catalog.rb +40 -29
  73. data/lib/puppet/ssl/certificate_revocation_list.rb +0 -2
  74. data/lib/puppet/ssl/host.rb +2 -3
  75. data/lib/puppet/sslcertificates/ca.rb +0 -5
  76. data/lib/puppet/type/cron.rb +1 -1
  77. data/lib/puppet/type/file/owner.rb +7 -4
  78. data/lib/puppet/type/resources.rb +17 -17
  79. data/lib/puppet/type/yumrepo.rb +10 -3
  80. data/lib/puppet/util.rb +6 -11
  81. data/lib/puppet/util/inifile.rb +8 -0
  82. data/lib/puppet/util/log.rb +2 -2
  83. data/lib/puppet/util/monkey_patches.rb +0 -43
  84. data/lib/puppet/util/{json.rb → pson.rb} +6 -6
  85. data/lib/puppet/util/rdoc.rb +5 -3
  86. data/lib/puppet/util/selinux.rb +12 -6
  87. data/lib/puppet/util/settings.rb +25 -16
  88. data/lib/puppet/util/settings/file_setting.rb +4 -2
  89. data/spec/integration/application/puppet.rb +4 -4
  90. data/spec/integration/defaults.rb +2 -2
  91. data/spec/integration/indirector/catalog/queue.rb +5 -5
  92. data/spec/integration/indirector/certificate/rest.rb +3 -1
  93. data/spec/integration/network/formats.rb +36 -36
  94. data/spec/integration/parser/functions/require.rb +5 -3
  95. data/spec/integration/provider/mailalias/aliases.rb +4 -4
  96. data/spec/integration/resource/catalog.rb +4 -4
  97. data/spec/unit/application/puppet.rb +16 -15
  98. data/spec/unit/application/puppetd.rb +1 -1
  99. data/spec/unit/application/puppetdoc.rb +6 -0
  100. data/spec/unit/application/puppetmasterd.rb +6 -6
  101. data/spec/unit/configurer/fact_handler.rb +3 -3
  102. data/spec/unit/file_serving/configuration.rb +16 -2
  103. data/spec/unit/indirector/certificate/rest.rb +34 -0
  104. data/spec/unit/indirector/queue.rb +15 -15
  105. data/spec/unit/indirector/rest.rb +31 -9
  106. data/spec/unit/network/authstore.rb +105 -26
  107. data/spec/unit/network/formats.rb +124 -39
  108. data/spec/unit/parser/ast/leaf.rb +15 -0
  109. data/spec/unit/parser/collector.rb +20 -9
  110. data/spec/unit/parser/compiler.rb +19 -0
  111. data/spec/unit/parser/functions/fqdn_rand.rb +62 -0
  112. data/spec/unit/parser/functions/regsubst.rb +80 -0
  113. data/spec/unit/parser/functions/require.rb +19 -7
  114. data/spec/unit/parser/interpreter.rb +2 -2
  115. data/spec/unit/parser/lexer.rb +32 -7
  116. data/spec/unit/parser/loaded_code.rb +18 -1
  117. data/spec/unit/parser/parser.rb +10 -2
  118. data/spec/unit/parser/resource.rb +53 -2
  119. data/spec/unit/parser/scope.rb +1 -1
  120. data/spec/unit/property.rb +14 -4
  121. data/spec/unit/provider/package/dpkg.rb +7 -0
  122. data/spec/unit/provider/service/daemontools.rb +19 -2
  123. data/spec/unit/provider/service/redhat.rb +2 -0
  124. data/spec/unit/provider/service/runit.rb +15 -4
  125. data/spec/unit/provider/ssh_authorized_key/parsed.rb +32 -55
  126. data/spec/unit/relationship.rb +21 -46
  127. data/spec/unit/resource.rb +30 -39
  128. data/spec/unit/resource/catalog.rb +66 -51
  129. data/spec/unit/ssl/certificate_revocation_list.rb +0 -12
  130. data/spec/unit/type/cron.rb +33 -0
  131. data/spec/unit/type/file/owner.rb +10 -4
  132. data/spec/unit/util/json.rb +9 -9
  133. data/spec/unit/util/log.rb +36 -0
  134. data/spec/unit/util/settings.rb +6 -0
  135. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys2 +1 -0
  136. data/test/lib/puppettest/support/utils.rb +8 -16
  137. metadata +36 -13
  138. data/lib/puppet/feature/json.rb +0 -2
@@ -36,6 +36,10 @@ class Puppet::Parser::LoadedCode
36
36
  nil
37
37
  end
38
38
 
39
+ def node_exists?(name)
40
+ @nodes[check_name(name)]
41
+ end
42
+
39
43
  def nodes?
40
44
  @nodes.length > 0
41
45
  end
@@ -376,7 +376,7 @@ class Puppet::Parser::Parser
376
376
  doc = lexer.getcomment
377
377
  names.collect do |name|
378
378
  name = AST::HostName.new :value => name unless name.is_a?(AST::HostName)
379
- if other = @loaded_code.node(name)
379
+ if other = @loaded_code.node_exists?(name)
380
380
  error("Node %s is already defined at %s:%s; cannot redefine" % [other.name, other.file, other.line])
381
381
  end
382
382
  name = name.to_s if name.is_a?(Symbol)
@@ -484,7 +484,10 @@ class Puppet::Parser::Parser
484
484
  return @version
485
485
  end
486
486
 
487
- @version = %x{#{Puppet[:config_version]}}.chomp
487
+ @version = Puppet::Util.execute([Puppet[:config_version]]).strip
488
+
489
+ rescue Puppet::ExecutionFailure => e
490
+ raise Puppet::ParseError, "Unable to set config_version: #{e.message}"
488
491
  end
489
492
 
490
493
  # Add a new file to be checked when we're checking to see if we should be
@@ -17,7 +17,7 @@ class Puppet::Parser::Resource
17
17
  include Puppet::Parser::YamlTrimmer
18
18
 
19
19
  attr_accessor :source, :scope, :rails_id
20
- attr_accessor :virtual, :override, :translated
20
+ attr_accessor :virtual, :override, :translated, :catalog
21
21
 
22
22
  attr_reader :exported, :evaluated, :params
23
23
 
@@ -139,6 +139,12 @@ class Puppet::Parser::Resource
139
139
  if params = options[:params]
140
140
  options.delete(:params)
141
141
  params.each do |param|
142
+ # Don't set the same parameter twice
143
+ if @params[param.name]
144
+ self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" %
145
+ [param.name, self.to_s]
146
+ end
147
+
142
148
  set_parameter(param)
143
149
  end
144
150
  end
@@ -175,6 +181,11 @@ class Puppet::Parser::Resource
175
181
  end
176
182
  end
177
183
 
184
+ # Unless we're running >= 0.25, we're in compat mode.
185
+ def metaparam_compatibility_mode?
186
+ ! (catalog and version = catalog.client_version and version = version.split(".") and version[0] == "0" and version[1].to_i >= 25)
187
+ end
188
+
178
189
  # Return the resource name, or the title if no name
179
190
  # was specified.
180
191
  def name
@@ -304,20 +315,34 @@ class Puppet::Parser::Resource
304
315
  end
305
316
  end
306
317
 
318
+ def add_backward_compatible_relationship_param(name)
319
+ # Skip metaparams for which we get no value.
320
+ return unless val = scope.lookupvar(name.to_s, false) and val != :undefined
321
+
322
+ # The default case: just set the value
323
+ set_parameter(name, val) and return unless @params[name]
324
+
325
+ # For relationship params, though, join the values (a la #446).
326
+ @params[name].value = [@params[name].value, val].flatten
327
+ end
328
+
307
329
  # Add any metaparams defined in our scope. This actually adds any metaparams
308
330
  # from any parent scope, and there's currently no way to turn that off.
309
331
  def add_metaparams
332
+ compat_mode = metaparam_compatibility_mode?
333
+
310
334
  Puppet::Type.eachmetaparam do |name|
311
- next if self.class.relationship_parameter?(name)
312
- # Skip metaparams that we already have defined, unless they're relationship metaparams.
313
- # LAK:NOTE Relationship metaparams get treated specially -- we stack them, instead of
314
- # overriding.
335
+ if self.class.relationship_parameter?(name)
336
+ add_backward_compatible_relationship_param(name) if compat_mode
337
+ next
338
+ end
339
+
315
340
  next if @params[name]
316
341
 
317
342
  # Skip metaparams for which we get no value.
318
343
  next unless val = scope.lookupvar(name.to_s, false) and val != :undefined
319
344
 
320
- set_parameter(name, val) and next unless @params[name]
345
+ set_parameter(name, val)
321
346
  end
322
347
  end
323
348
 
@@ -1,4 +1,4 @@
1
- # The virtual base class for properties, which are the self-contained building
1
+ # The virtual base class for properties, which are the self-contained building
2
2
  # blocks for actually doing work on the system.
3
3
 
4
4
  require 'puppet'
@@ -144,6 +144,7 @@ class Puppet::Property < Puppet::Parameter
144
144
  rescue Puppet::Error, Puppet::DevError
145
145
  raise
146
146
  rescue => detail
147
+ puts detail.backtrace if Puppet[:trace]
147
148
  raise Puppet::DevError, "Could not convert change %s to string: %s" %
148
149
  [self.name, detail]
149
150
  end
@@ -384,7 +385,7 @@ class Puppet::Property < Puppet::Parameter
384
385
  # Make sure that we've got all of the required features for a given value.
385
386
  def validate_features_per_value(value)
386
387
  if features = self.class.value_option(self.class.value_name(value), :required_features)
387
- raise ArgumentError, "Provider must have features '%s' to set '%s' to '%s'" % [features.collect { |f| f.to_s }.join(", "), self.class.name, value] unless provider.satisfies?(features)
388
+ raise ArgumentError, "Provider must have features '%s' to set '%s' to '%s'" % [[features].flatten.join(", "), self.class.name, value] unless provider.satisfies?(features)
388
389
  end
389
390
  end
390
391
 
@@ -226,11 +226,18 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
226
226
  # This mainly converts the keys from the puppet attributes to the
227
227
  # 'native' ones, but also enforces that the keys are all Strings
228
228
  # rather than Symbols so that any merges of the resultant Hash are
229
- # sane.
229
+ # sane. The exception is booleans, where we coerce to a proper bool
230
+ # if they come in as a symbol.
230
231
  newplist = {}
231
232
  propertylist.each_pair do |key, value|
232
233
  next if key == :ensure # not part of the auth db schema.
233
234
  next if key == :auth_type # not part of the auth db schema.
235
+ case value
236
+ when true, :true
237
+ value = true
238
+ when false, :false
239
+ value = false
240
+ end
234
241
  new_key = key
235
242
  if PuppetToNativeAttributeMap.has_key?(key)
236
243
  new_key = PuppetToNativeAttributeMap[key].to_s
@@ -243,7 +250,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
243
250
  end
244
251
 
245
252
  def retrieve_value(resource_name, attribute)
246
-
253
+ # We set boolean values to symbols when retrieving values
247
254
  if not self.class.parsed_auth_db.has_key?(resource_name)
248
255
  raise Puppet::Error.new("Cannot find #{resource_name} in auth db")
249
256
  end
@@ -257,10 +264,10 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
257
264
  if self.class.parsed_auth_db[resource_name].has_key?(native_attribute)
258
265
  value = self.class.parsed_auth_db[resource_name][native_attribute]
259
266
  case value
260
- when true, "true", :true
261
- value = true
262
- when false, "false", :false
263
- value = false
267
+ when true, :true
268
+ value = :true
269
+ when false, :false
270
+ value = :false
264
271
  end
265
272
 
266
273
  @property_hash[attribute] = value
@@ -287,14 +294,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
287
294
  end
288
295
 
289
296
  define_method(field.to_s + "=") do |value|
290
- case value
291
- when true, "true", :true
292
- @property_hash[field] = true
293
- when false, "false", :false
294
- @property_hash[field] = false
295
- else
296
- @property_hash[field] = value
297
- end
297
+ @property_hash[field] = value
298
298
  end
299
299
  end
300
300
 
@@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
83
83
  def latest
84
84
  output = dpkg_deb "--show", @resource[:source]
85
85
  matches = /^(\S+)\t(\S+)$/.match(output).captures
86
- unless matches[0].match(@resource[:name])
86
+ unless matches[0].match( Regexp.escape(@resource[:name]) )
87
87
  warning "source doesn't contain named package, but %s" % matches[0]
88
88
  end
89
89
  matches[1]
@@ -1,11 +1,12 @@
1
1
  require 'puppet/provider/package'
2
2
 
3
3
  Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Package do
4
+ include Puppet::Util::Execution
4
5
  desc "Provides packaging support for Gentoo's portage system."
5
6
 
6
7
  has_feature :versionable
7
8
 
8
- commands :emerge => "/usr/bin/emerge", :eix => "/usr/bin/eix", :update_eix => "/usr/bin/update-eix"
9
+ commands :emerge => "/usr/bin/emerge", :eix => "/usr/bin/eix", :update_eix => "/usr/bin/eix-update"
9
10
 
10
11
  confine :operatingsystem => :gentoo
11
12
 
@@ -15,13 +16,17 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
15
16
  result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/
16
17
  result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description]
17
18
 
18
- search_format = "{installedversionsshort}<category> <name> [<installedversionsshort>] [<best>] <homepage> <description>{}"
19
+ version_format = "<version>{!last} {}"
20
+ search_format = "<category> <name> [<installedversions:SPLITVERSIONS>] [<bestversion:SPLITVERSIONS>] <homepage> <description>"
19
21
 
20
22
  begin
21
23
  if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
22
24
  update_eix
23
25
  end
24
- search_output = eix "--nocolor", "--format", search_format
26
+ search_output = nil
27
+ withenv :SPLITVERSIONS => version_format do
28
+ search_output = eix "--nocolor", "--pure-packages", "--installed", "--format", search_format
29
+ end
25
30
 
26
31
  packages = []
27
32
  search_output.each do |search_result|
@@ -74,13 +79,18 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
74
79
 
75
80
  search_field = package_name.count('/') > 0 ? "--category-name" : "--name"
76
81
  search_value = package_name
77
- search_format = "<category> <name> [<installedversionsshort>] [<best>] <homepage> <description>"
82
+
83
+ version_format = "<version>{!last} {}"
84
+ search_format = "<category> <name> [<installedversions:FORMAT_PVERSION>] [<bestversion:FORMAT_PVERSION>] <homepage> <description>"
78
85
 
79
86
  begin
80
87
  if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
81
88
  update_eix
82
89
  end
83
- search_output = eix "--nocolor", "--format", search_format, "--exact", search_field, search_value
90
+ search_output = nil
91
+ withenv :SPLITVERSIONS => version_format do
92
+ search_output = eix "--nocolor", "--pure-packages", "--format", search_format, "--exact", search_field, search_value
93
+ end
84
94
 
85
95
  packages = []
86
96
  search_output.each do |search_result|
@@ -36,7 +36,7 @@ Puppet::Type.type(:package).provide :rug, :parent => :rpm do
36
36
  #rug can only get a list of *all* available packages?
37
37
  output = rug "list-updates"
38
38
 
39
- if output =~ /#{@resource[:name]}\s*\|\s*([0-9\.\-]+)/
39
+ if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([0-9\.\-]+)/
40
40
  return $1
41
41
  else
42
42
  # rug didn't find updates, pretend the current
@@ -25,7 +25,7 @@ Puppet::Type.type(:package).provide :up2date, :parent => :rpm, :source => :rpm d
25
25
  #up2date can only get a list of *all* available packages?
26
26
  output = up2date "--showall"
27
27
 
28
- if output =~ /^#{@resource[:name]}-(\d+.*)\.\w+/
28
+ if output =~ /^#{Regexp.escape @resource[:name]}-(\d+.*)\.\w+/
29
29
  return $1
30
30
  else
31
31
  # up2date didn't find updates, pretend the current
@@ -43,7 +43,7 @@ Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do
43
43
  def latest
44
44
  output = urpmq "-S", @resource[:name]
45
45
 
46
- if output =~ /^#{@resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/
46
+ if output =~ /^#{Regexp.escape @resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/
47
47
  return $1
48
48
  else
49
49
  # urpmi didn't find updates, pretend the current
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # author Brice Figureau <brice-puppet@daysofwonder.com>
4
4
  Puppet::Type.type(:service).provide :daemontools, :parent => :base do
5
- desc """Daemontools service management.
5
+ desc "Daemontools service management.
6
6
 
7
7
  This provider manages daemons running supervised by D.J.Bernstein daemontools.
8
8
  It tries to detect the service directory, with by order of preference:
@@ -37,7 +37,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
37
37
  If a service has ensure => \"stopped\", it will only down the service, not
38
38
  remove the /path/to/service link.
39
39
 
40
- """
40
+ "
41
41
 
42
42
  commands :svc => "/usr/bin/svc", :svstat => "/usr/bin/svstat"
43
43
 
@@ -124,11 +124,6 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
124
124
  return :stopped
125
125
  end
126
126
 
127
- def startcmd
128
- self.enable if ! FileTest.symlink?(self.service)
129
- [command(:svc), "-u", self.service ]
130
- end
131
-
132
127
  def setupservice
133
128
  begin
134
129
  if resource[:manifest]
@@ -144,10 +139,12 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
144
139
 
145
140
  def enabled?
146
141
  case self.status
147
- when :running:
142
+ when :running
143
+ # obviously if the daemon is running then it is enabled
148
144
  return :true
149
145
  else
150
- return :false
146
+ # the service is enabled if it is linked
147
+ return FileTest.symlink?(self.service) ? :true : :false
151
148
  end
152
149
  end
153
150
 
@@ -191,7 +188,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
191
188
  end
192
189
 
193
190
  def start
194
- enable unless enabled?
191
+ enable unless enabled? == :true
195
192
  svc "-u", self.service
196
193
  end
197
194
 
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # author Brice Figureau <brice-puppet@daysofwonder.com>
4
4
  Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
5
- desc """Runit service management.
5
+ desc "Runit service management.
6
6
 
7
7
  This provider manages daemons running supervised by Runit.
8
8
  It tries to detect the service directory, with by order of preference:
@@ -31,7 +31,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
31
31
  * status
32
32
 
33
33
 
34
- """
34
+ "
35
35
 
36
36
  commands :sv => "/usr/bin/sv"
37
37
 
@@ -66,10 +66,6 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
66
66
  @servicedir
67
67
  end
68
68
 
69
- def restartcmd
70
- [ command(:sv), "restart", self.service]
71
- end
72
-
73
69
  def status
74
70
  begin
75
71
  output = sv "status", self.daemon
@@ -82,23 +78,17 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
82
78
  return :stopped
83
79
  end
84
80
 
85
- # relay to the stopcmd
86
81
  def stop
87
- ucommand( :stop )
88
- end
89
-
90
- def stopcmd
91
- [ command(:sv), "stop", self.service]
82
+ sv "stop", self.service
92
83
  end
93
84
 
94
- # relay to the startcmd
95
85
  def start
96
- enable unless enabled?
97
- ucommand( :start )
86
+ enable unless enabled? == :true
87
+ sv "start", self.service
98
88
  end
99
89
 
100
- def startcmd
101
- [ command(:sv), "start", self.service]
90
+ def restart
91
+ sv "restart", self.service
102
92
  end
103
93
 
104
94
  # disable by removing the symlink so that runit
@@ -15,19 +15,13 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
15
15
  :optional => %w{options},
16
16
  :rts => /^\s+/,
17
17
  :match => /^(?:(.+) )?(ssh-dss|ssh-rsa) ([^ ]+)(?: (.+))?$/,
18
- :post_parse => proc { |record|
19
- if record[:options].nil?
20
- record[:options] = [:absent]
21
- else
22
- record[:options] = Puppet::Type::Ssh_authorized_key::ProviderParsed.parse_options(record[:options])
23
- end
18
+ :post_parse => proc { |h|
19
+ h[:options] ||= [:absent]
20
+ h[:options] = Puppet::Type::Ssh_authorized_key::ProviderParsed.parse_options(h[:options]) if h[:options].is_a? String
24
21
  },
25
- :pre_gen => proc { |record|
26
- if record[:options].include?(:absent)
27
- record[:options] = ""
28
- else
29
- record[:options] = record[:options].join(',')
30
- end
22
+ :pre_gen => proc { |h|
23
+ h[:options] = [] if h[:options].include?(:absent)
24
+ h[:options] = h[:options].join(',')
31
25
  }
32
26
 
33
27
  record_line :key_v1,
@@ -36,14 +30,6 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
36
30
  :rts => /^\s+/,
37
31
  :match => /^(?:(.+) )?(\d+) (\d+) (\d+)(?: (.+))?$/
38
32
 
39
- def target
40
- @resource.should(:target)
41
- end
42
-
43
- def user
44
- @resource.should(:user)
45
- end
46
-
47
33
  def dir_perm
48
34
  # Determine correct permission for created directory and file
49
35
  # we can afford more restrictive permissions when the user is known
@@ -67,39 +53,13 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
67
53
  end
68
54
 
69
55
  def target
70
- if user
71
- File.expand_path("~%s/.ssh/authorized_keys" % user)
72
- elsif target = @resource.should(:target)
73
- target
74
- end
56
+ @resource.should(:target) || File.expand_path("~%s/.ssh/authorized_keys" % user)
75
57
  end
76
58
 
77
59
  def user
78
60
  @resource.should(:user)
79
61
  end
80
62
 
81
- def dir_perm
82
- # Determine correct permission for created directory and file
83
- # we can afford more restrictive permissions when the user is known
84
- if target
85
- if user
86
- 0700
87
- else
88
- 0755
89
- end
90
- end
91
- end
92
-
93
- def file_perm
94
- if target
95
- if user
96
- 0600
97
- else
98
- 0644
99
- end
100
- end
101
- end
102
-
103
63
  def flush
104
64
  # As path expansion had to be moved in the provider, we cannot generate new file
105
65
  # resources and thus have to chown and chmod here. It smells hackish.