puppet 6.6.0-x86-mingw32 → 6.7.0-x86-mingw32

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 (254) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -8
  3. data/ext/solaris/smf/puppet.xml +2 -0
  4. data/ext/yaml_nodes.rb +7 -7
  5. data/lib/hiera_puppet.rb +2 -1
  6. data/lib/puppet/application/apply.rb +2 -3
  7. data/lib/puppet/application/doc.rb +2 -1
  8. data/lib/puppet/application/face_base.rb +22 -15
  9. data/lib/puppet/application/script.rb +4 -6
  10. data/lib/puppet/configurer.rb +10 -5
  11. data/lib/puppet/confine_collection.rb +2 -1
  12. data/lib/puppet/daemon.rb +3 -2
  13. data/lib/puppet/defaults.rb +8 -0
  14. data/lib/puppet/environments.rb +9 -7
  15. data/lib/puppet/etc.rb +1 -1
  16. data/lib/puppet/external/pson/pure/parser.rb +2 -1
  17. data/lib/puppet/face/epp.rb +4 -2
  18. data/lib/puppet/face/help.rb +3 -2
  19. data/lib/puppet/face/module/changes.rb +2 -1
  20. data/lib/puppet/file_bucket/dipper.rb +2 -1
  21. data/lib/puppet/file_serving/configuration.rb +2 -1
  22. data/lib/puppet/file_serving/fileset.rb +1 -1
  23. data/lib/puppet/file_serving/http_metadata.rb +4 -2
  24. data/lib/puppet/file_serving/metadata.rb +2 -1
  25. data/lib/puppet/file_serving/mount/file.rb +2 -1
  26. data/lib/puppet/file_serving/mount/locales.rb +2 -1
  27. data/lib/puppet/file_serving/mount/modules.rb +4 -2
  28. data/lib/puppet/file_serving/mount/pluginfacts.rb +2 -1
  29. data/lib/puppet/file_serving/mount/plugins.rb +2 -1
  30. data/lib/puppet/file_serving/mount/tasks.rb +4 -2
  31. data/lib/puppet/file_system/uniquefile.rb +4 -2
  32. data/lib/puppet/functions/match.rb +2 -3
  33. data/lib/puppet/generate/type.rb +2 -1
  34. data/lib/puppet/graph/relationship_graph.rb +2 -1
  35. data/lib/puppet/graph/simple_graph.rb +3 -2
  36. data/lib/puppet/indirector/catalog/compiler.rb +16 -8
  37. data/lib/puppet/indirector/certificate/rest.rb +2 -1
  38. data/lib/puppet/indirector/face.rb +2 -2
  39. data/lib/puppet/indirector/file_server.rb +4 -2
  40. data/lib/puppet/indirector/indirection.rb +12 -6
  41. data/lib/puppet/indirector/node/exec.rb +2 -1
  42. data/lib/puppet/indirector/report/processor.rb +2 -1
  43. data/lib/puppet/indirector/request.rb +9 -5
  44. data/lib/puppet/indirector/ssl_file.rb +10 -8
  45. data/lib/puppet/indirector/terminus.rb +6 -3
  46. data/lib/puppet/info_service.rb +9 -0
  47. data/lib/puppet/info_service/plan_information_service.rb +36 -0
  48. data/lib/puppet/interface.rb +2 -1
  49. data/lib/puppet/interface/action.rb +10 -5
  50. data/lib/puppet/interface/action_manager.rb +2 -1
  51. data/lib/puppet/interface/documentation.rb +10 -7
  52. data/lib/puppet/interface/face_collection.rb +6 -3
  53. data/lib/puppet/interface/option.rb +4 -2
  54. data/lib/puppet/interface/option_manager.rb +4 -2
  55. data/lib/puppet/module.rb +35 -1
  56. data/lib/puppet/module/plan.rb +160 -0
  57. data/lib/puppet/module_tool.rb +2 -1
  58. data/lib/puppet/module_tool/applications/application.rb +2 -1
  59. data/lib/puppet/module_tool/applications/installer.rb +4 -2
  60. data/lib/puppet/module_tool/applications/upgrader.rb +4 -2
  61. data/lib/puppet/module_tool/contents_description.rb +2 -1
  62. data/lib/puppet/module_tool/metadata.rb +2 -3
  63. data/lib/puppet/module_tool/shared_behaviors.rb +2 -1
  64. data/lib/puppet/network/authconfig.rb +4 -2
  65. data/lib/puppet/network/authstore.rb +2 -1
  66. data/lib/puppet/network/formats.rb +2 -1
  67. data/lib/puppet/network/http/api/indirected_routes.rb +6 -4
  68. data/lib/puppet/network/http/handler.rb +2 -1
  69. data/lib/puppet/network/http/request.rb +2 -1
  70. data/lib/puppet/network/http/route.rb +2 -1
  71. data/lib/puppet/network/resolver.rb +3 -2
  72. data/lib/puppet/network/rights.rb +2 -1
  73. data/lib/puppet/node.rb +8 -4
  74. data/lib/puppet/pal/catalog_compiler.rb +8 -1
  75. data/lib/puppet/pal/compiler.rb +2 -1
  76. data/lib/puppet/pal/pal_impl.rb +8 -0
  77. data/lib/puppet/pal/script_compiler.rb +4 -2
  78. data/lib/puppet/parameter.rb +4 -2
  79. data/lib/puppet/parameter/value_collection.rb +8 -8
  80. data/lib/puppet/parser/ast/pops_bridge.rb +2 -1
  81. data/lib/puppet/parser/compiler.rb +10 -5
  82. data/lib/puppet/parser/files.rb +2 -1
  83. data/lib/puppet/parser/functions.rb +2 -1
  84. data/lib/puppet/parser/relationship.rb +2 -1
  85. data/lib/puppet/parser/resource.rb +6 -3
  86. data/lib/puppet/parser/scope.rb +6 -4
  87. data/lib/puppet/parser/templatewrapper.rb +2 -1
  88. data/lib/puppet/parser/type_loader.rb +2 -1
  89. data/lib/puppet/pops/adaptable.rb +2 -5
  90. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +2 -1
  91. data/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +2 -1
  92. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -1
  93. data/lib/puppet/pops/evaluator/runtime3_support.rb +8 -4
  94. data/lib/puppet/pops/loader/base_loader.rb +4 -2
  95. data/lib/puppet/pops/loader/dependency_loader.rb +4 -2
  96. data/lib/puppet/pops/loader/gem_support.rb +4 -2
  97. data/lib/puppet/pops/loader/loader.rb +4 -2
  98. data/lib/puppet/pops/loader/loader_paths.rb +2 -1
  99. data/lib/puppet/pops/loader/static_loader.rb +1 -1
  100. data/lib/puppet/pops/lookup/interpolation.rb +2 -1
  101. data/lib/puppet/pops/model/factory.rb +4 -2
  102. data/lib/puppet/pops/parser/epp_support.rb +2 -1
  103. data/lib/puppet/pops/parser/heredoc_support.rb +2 -1
  104. data/lib/puppet/pops/parser/interpolation_support.rb +10 -5
  105. data/lib/puppet/pops/parser/lexer2.rb +6 -3
  106. data/lib/puppet/pops/parser/locator.rb +2 -1
  107. data/lib/puppet/pops/types/type_calculator.rb +1 -1
  108. data/lib/puppet/pops/types/type_parser.rb +4 -2
  109. data/lib/puppet/pops/validation.rb +2 -1
  110. data/lib/puppet/pops/validation/checker4_0.rb +6 -3
  111. data/lib/puppet/pops/visitor.rb +12 -6
  112. data/lib/puppet/property.rb +19 -16
  113. data/lib/puppet/property/ensure.rb +2 -1
  114. data/lib/puppet/property/keyvalue.rb +2 -1
  115. data/lib/puppet/property/list.rb +2 -1
  116. data/lib/puppet/provider.rb +10 -8
  117. data/lib/puppet/provider/exec.rb +7 -4
  118. data/lib/puppet/provider/file/posix.rb +6 -3
  119. data/lib/puppet/provider/group/groupadd.rb +2 -1
  120. data/lib/puppet/provider/group/ldap.rb +7 -4
  121. data/lib/puppet/provider/group/pw.rb +4 -2
  122. data/lib/puppet/provider/ldap.rb +8 -4
  123. data/lib/puppet/provider/nameservice.rb +8 -5
  124. data/lib/puppet/provider/nameservice/directoryservice.rb +8 -4
  125. data/lib/puppet/provider/network_device.rb +4 -2
  126. data/lib/puppet/provider/package.rb +2 -1
  127. data/lib/puppet/provider/package/aix.rb +4 -2
  128. data/lib/puppet/provider/package/appdmg.rb +4 -2
  129. data/lib/puppet/provider/package/apple.rb +2 -1
  130. data/lib/puppet/provider/package/apt.rb +4 -2
  131. data/lib/puppet/provider/package/blastwave.rb +2 -1
  132. data/lib/puppet/provider/package/dpkg.rb +6 -3
  133. data/lib/puppet/provider/package/fink.rb +2 -1
  134. data/lib/puppet/provider/package/gem.rb +4 -2
  135. data/lib/puppet/provider/package/macports.rb +6 -3
  136. data/lib/puppet/provider/package/nim.rb +8 -4
  137. data/lib/puppet/provider/package/openbsd.rb +14 -8
  138. data/lib/puppet/provider/package/opkg.rb +2 -1
  139. data/lib/puppet/provider/package/pacman.rb +2 -1
  140. data/lib/puppet/provider/package/pip.rb +2 -1
  141. data/lib/puppet/provider/package/pkgdmg.rb +4 -2
  142. data/lib/puppet/provider/package/pkgng.rb +4 -2
  143. data/lib/puppet/provider/package/pkgutil.rb +2 -1
  144. data/lib/puppet/provider/package/portupgrade.rb +2 -1
  145. data/lib/puppet/provider/package/rpm.rb +8 -4
  146. data/lib/puppet/provider/package/windows/package.rb +2 -1
  147. data/lib/puppet/provider/parsedfile.rb +14 -7
  148. data/lib/puppet/provider/service/base.rb +7 -4
  149. data/lib/puppet/provider/service/launchd.rb +4 -2
  150. data/lib/puppet/provider/service/service.rb +2 -1
  151. data/lib/puppet/provider/service/upstart.rb +11 -8
  152. data/lib/puppet/provider/user/directoryservice.rb +2 -1
  153. data/lib/puppet/provider/user/hpux.rb +1 -1
  154. data/lib/puppet/provider/user/ldap.rb +8 -4
  155. data/lib/puppet/provider/user/openbsd.rb +2 -1
  156. data/lib/puppet/provider/user/pw.rb +2 -1
  157. data/lib/puppet/provider/user/user_role_add.rb +4 -2
  158. data/lib/puppet/provider/user/useradd.rb +7 -4
  159. data/lib/puppet/reference/providers.rb +2 -3
  160. data/lib/puppet/reference/type.rb +4 -2
  161. data/lib/puppet/relationship.rb +4 -9
  162. data/lib/puppet/resource.rb +16 -9
  163. data/lib/puppet/resource/capability_finder.rb +12 -8
  164. data/lib/puppet/resource/catalog.rb +36 -40
  165. data/lib/puppet/resource/type.rb +7 -3
  166. data/lib/puppet/resource/type_collection.rb +4 -2
  167. data/lib/puppet/settings.rb +36 -19
  168. data/lib/puppet/settings/base_setting.rb +2 -1
  169. data/lib/puppet/settings/config_file.rb +2 -1
  170. data/lib/puppet/settings/file_setting.rb +2 -1
  171. data/lib/puppet/settings/ini_file.rb +2 -1
  172. data/lib/puppet/ssl/base.rb +2 -1
  173. data/lib/puppet/ssl/host.rb +16 -8
  174. data/lib/puppet/ssl/key.rb +2 -2
  175. data/lib/puppet/ssl/state_machine.rb +22 -3
  176. data/lib/puppet/transaction/event.rb +2 -1
  177. data/lib/puppet/transaction/event_manager.rb +4 -2
  178. data/lib/puppet/transaction/report.rb +10 -10
  179. data/lib/puppet/transaction/resource_harness.rb +4 -2
  180. data/lib/puppet/type.rb +84 -48
  181. data/lib/puppet/type/component.rb +2 -1
  182. data/lib/puppet/type/exec.rb +11 -7
  183. data/lib/puppet/type/file.rb +15 -9
  184. data/lib/puppet/type/file/content.rb +7 -3
  185. data/lib/puppet/type/file/ctime.rb +2 -1
  186. data/lib/puppet/type/file/data_sync.rb +2 -1
  187. data/lib/puppet/type/file/ensure.rb +10 -7
  188. data/lib/puppet/type/file/mode.rb +2 -1
  189. data/lib/puppet/type/file/mtime.rb +2 -1
  190. data/lib/puppet/type/file/selcontext.rb +2 -1
  191. data/lib/puppet/type/file/source.rb +6 -7
  192. data/lib/puppet/type/file/target.rb +2 -1
  193. data/lib/puppet/type/file/type.rb +2 -1
  194. data/lib/puppet/type/package.rb +6 -3
  195. data/lib/puppet/type/resources.rb +2 -1
  196. data/lib/puppet/type/service.rb +2 -1
  197. data/lib/puppet/type/tidy.rb +14 -7
  198. data/lib/puppet/type/user.rb +19 -7
  199. data/lib/puppet/util.rb +6 -3
  200. data/lib/puppet/util/checksums.rb +1 -1
  201. data/lib/puppet/util/classgen.rb +12 -6
  202. data/lib/puppet/util/command_line.rb +8 -4
  203. data/lib/puppet/util/connection.rb +4 -2
  204. data/lib/puppet/util/diff.rb +4 -2
  205. data/lib/puppet/util/execution.rb +4 -2
  206. data/lib/puppet/util/feature.rb +7 -4
  207. data/lib/puppet/util/fileparsing.rb +57 -46
  208. data/lib/puppet/util/filetype.rb +2 -1
  209. data/lib/puppet/util/http_proxy.rb +2 -1
  210. data/lib/puppet/util/instance_loader.rb +2 -1
  211. data/lib/puppet/util/ldap/connection.rb +4 -2
  212. data/lib/puppet/util/ldap/manager.rb +6 -3
  213. data/lib/puppet/util/log.rb +6 -3
  214. data/lib/puppet/util/metric.rb +2 -1
  215. data/lib/puppet/util/posix.rb +4 -2
  216. data/lib/puppet/util/rdoc/code_objects.rb +2 -1
  217. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +4 -2
  218. data/lib/puppet/util/selinux.rb +2 -1
  219. data/lib/puppet/version.rb +2 -5
  220. data/locales/puppet.pot +713 -685
  221. data/man/man5/puppet.conf.5 +9 -2
  222. data/man/man8/puppet-agent.8 +1 -1
  223. data/man/man8/puppet-apply.8 +1 -1
  224. data/man/man8/puppet-catalog.8 +1 -1
  225. data/man/man8/puppet-config.8 +1 -1
  226. data/man/man8/puppet-describe.8 +1 -1
  227. data/man/man8/puppet-device.8 +1 -1
  228. data/man/man8/puppet-doc.8 +1 -1
  229. data/man/man8/puppet-epp.8 +1 -1
  230. data/man/man8/puppet-facts.8 +1 -1
  231. data/man/man8/puppet-filebucket.8 +1 -1
  232. data/man/man8/puppet-generate.8 +1 -1
  233. data/man/man8/puppet-help.8 +1 -1
  234. data/man/man8/puppet-key.8 +1 -1
  235. data/man/man8/puppet-lookup.8 +1 -1
  236. data/man/man8/puppet-man.8 +1 -1
  237. data/man/man8/puppet-module.8 +1 -1
  238. data/man/man8/puppet-node.8 +1 -1
  239. data/man/man8/puppet-parser.8 +1 -1
  240. data/man/man8/puppet-plugin.8 +1 -1
  241. data/man/man8/puppet-report.8 +1 -1
  242. data/man/man8/puppet-resource.8 +1 -1
  243. data/man/man8/puppet-script.8 +1 -1
  244. data/man/man8/puppet-ssl.8 +1 -1
  245. data/man/man8/puppet-status.8 +1 -1
  246. data/man/man8/puppet.8 +2 -2
  247. data/spec/lib/puppet_spec/modules.rb +16 -2
  248. data/spec/unit/indirector/request_spec.rb +5 -6
  249. data/spec/unit/info_service_spec.rb +48 -0
  250. data/spec/unit/module_spec.rb +73 -0
  251. data/spec/unit/plan_spec.rb +65 -0
  252. data/spec/unit/puppet_pal_catalog_spec.rb +12 -0
  253. data/spec/unit/ssl/state_machine_spec.rb +68 -5
  254. metadata +6 -2
@@ -34,7 +34,8 @@ class TypeParser
34
34
  #
35
35
  def parse(string, context = nil)
36
36
  # quick "peephole" optimization of common data types
37
- if t = self.class.opt_type_map[string]
37
+ t = self.class.opt_type_map[string]
38
+ if t
38
39
  return t
39
40
  end
40
41
  model = @parser.parse_string(string)
@@ -276,7 +277,8 @@ class TypeParser
276
277
  # @api private
277
278
  def interpret_QualifiedReference(name_ast, context)
278
279
  name = name_ast.value
279
- if found = self.class.type_map[name]
280
+ found = self.class.type_map[name]
281
+ if found
280
282
  found
281
283
  else
282
284
  loader = loader_from_context(name_ast, context)
@@ -425,7 +425,8 @@ module Validation
425
425
  def prune(&block)
426
426
  removed = []
427
427
  @diagnostics.delete_if do |d|
428
- if should_remove = yield(d)
428
+ should_remove = yield(d)
429
+ if should_remove
429
430
  removed << d
430
431
  end
431
432
  should_remove
@@ -512,7 +512,8 @@ class Checker4_0 < Evaluator::LiteralEvaluator
512
512
  end
513
513
 
514
514
  def internal_check_no_idem_last(o)
515
- if violator = ends_with_idem(o.body)
515
+ violator = ends_with_idem(o.body)
516
+ if violator
516
517
  acceptor.accept(Issues::IDEM_NOT_ALLOWED_LAST, violator, {:container => o}) unless resource_without_title?(violator)
517
518
  end
518
519
  end
@@ -731,7 +732,8 @@ class Checker4_0 < Evaluator::LiteralEvaluator
731
732
  # Check that hostnames are valid hostnames (or regular expressions)
732
733
  hostname(o.host_matches, o)
733
734
  top(o)
734
- if violator = ends_with_idem(o.body)
735
+ violator = ends_with_idem(o.body)
736
+ if violator
735
737
  acceptor.accept(Issues::IDEM_NOT_ALLOWED_LAST, violator, {:container => o}) unless resource_without_title?(violator)
736
738
  end
737
739
  unless o.parent.nil?
@@ -917,7 +919,8 @@ class Checker4_0 < Evaluator::LiteralEvaluator
917
919
 
918
920
  def hostname_ConcatenatedString(o, semantic)
919
921
  # Puppet 3.1. only accepts a concatenated string without interpolated expressions
920
- if the_expr = o.segments.index {|s| s.is_a?(Model::TextExpression) }
922
+ the_expr = o.segments.index {|s| s.is_a?(Model::TextExpression) }
923
+ if the_expr
921
924
  acceptor.accept(Issues::ILLEGAL_HOSTNAME_INTERPOLATION, o.segments[the_expr].expr)
922
925
  elsif o.segments.size() != 1
923
926
  # corner case, bad model, concatenation of several plain strings
@@ -36,7 +36,8 @@ class Visitor
36
36
  if @max_args
37
37
  raise "Visitor Error: Too many arguments passed. max = #{@max_args}" unless args.length <= @max_args
38
38
  end
39
- if method_name = @cache[thing.class]
39
+ method_name = @cache[thing.class]
40
+ if method_name
40
41
  return receiver.send(method_name, thing, *args)
41
42
  else
42
43
  thing.class.ancestors().each do |ancestor|
@@ -57,7 +58,8 @@ class Visitor
57
58
  if @max_args
58
59
  raise "Visitor Error: Too many arguments passed. max = #{@max_args}" unless args.length <= @max_args
59
60
  end
60
- if method_name = @cache[clazz]
61
+ method_name = @cache[clazz]
62
+ if method_name
61
63
  return receiver.send(method_name, clazz, *args)
62
64
  else
63
65
  clazz.ancestors().each do |ancestor|
@@ -76,7 +78,8 @@ class Visitor
76
78
  # (This is ~30% faster than calling the general method)
77
79
  #
78
80
  def visit_this_0(receiver, thing)
79
- if method_name = @cache[thing.class]
81
+ method_name = @cache[thing.class]
82
+ if method_name
80
83
  return receiver.send(method_name, thing)
81
84
  end
82
85
  visit_this(receiver, thing, NO_ARGS)
@@ -86,7 +89,8 @@ class Visitor
86
89
  # (This is ~30% faster than calling the general method)
87
90
  #
88
91
  def visit_this_1(receiver, thing, arg)
89
- if method_name = @cache[thing.class]
92
+ method_name = @cache[thing.class]
93
+ if method_name
90
94
  return receiver.send(method_name, thing, arg)
91
95
  end
92
96
  visit_this(receiver, thing, [arg])
@@ -96,7 +100,8 @@ class Visitor
96
100
  # (This is ~30% faster than calling the general method)
97
101
  #
98
102
  def visit_this_2(receiver, thing, arg1, arg2)
99
- if method_name = @cache[thing.class]
103
+ method_name = @cache[thing.class]
104
+ if method_name
100
105
  return receiver.send(method_name, thing, arg1, arg2)
101
106
  end
102
107
  visit_this(receiver, thing, [arg1, arg2])
@@ -106,7 +111,8 @@ class Visitor
106
111
  # (This is ~30% faster than calling the general method)
107
112
  #
108
113
  def visit_this_3(receiver, thing, arg1, arg2, arg3)
109
- if method_name = @cache[thing.class]
114
+ method_name = @cache[thing.class]
115
+ if method_name
110
116
  return receiver.send(method_name, thing, arg1, arg2, arg3)
111
117
  end
112
118
  visit_this(receiver, thing, [arg1, arg2, arg3])
@@ -123,9 +123,8 @@ class Puppet::Property < Puppet::Parameter
123
123
  # @api private
124
124
  #
125
125
  def self.value_name(name)
126
- if value = value_collection.match?(name)
127
- value.name
128
- end
126
+ value = value_collection.match?(name)
127
+ value.name if value
129
128
  end
130
129
 
131
130
  # Returns the value of the given option (set when a valid value with the given "name" was defined).
@@ -137,9 +136,8 @@ class Puppet::Property < Puppet::Parameter
137
136
  # @api private
138
137
  #
139
138
  def self.value_option(name, option)
140
- if value = value_collection.value(name)
141
- value.send(option)
142
- end
139
+ value = value_collection.value(name)
140
+ value.send(option) if value
143
141
  end
144
142
 
145
143
  # Defines a new valid value for this property.
@@ -255,9 +253,9 @@ class Puppet::Property < Puppet::Parameter
255
253
  # @see Puppet::Type#event
256
254
  def event(options = {})
257
255
  attrs = { :name => event_name, :desired_value => should, :property => self, :source_description => path }.merge(options)
258
- if should and value = self.class.value_collection.match?(should)
259
- attrs[:invalidate_refreshes] = true if value.invalidate_refreshes
260
- end
256
+ value = self.class.value_collection.match?(should) if should
257
+
258
+ attrs[:invalidate_refreshes] = true if value && value.invalidate_refreshes
261
259
  attrs[:redacted] = @sensitive
262
260
  resource.event attrs
263
261
  end
@@ -486,7 +484,8 @@ class Puppet::Property < Puppet::Parameter
486
484
  def set(value)
487
485
  # Set a name for looking up associated options like the event.
488
486
  name = self.class.value_name(value)
489
- if method = self.class.value_option(name, :method) and self.respond_to?(method)
487
+ method = self.class.value_option(name, :method)
488
+ if method && self.respond_to?(method)
490
489
  begin
491
490
  self.send(method)
492
491
  rescue Puppet::Error
@@ -498,12 +497,15 @@ class Puppet::Property < Puppet::Parameter
498
497
  Puppet.log_exception(detail, error.message)
499
498
  raise error
500
499
  end
501
- elsif block = self.class.value_option(name, :block)
502
- # FIXME It'd be better here to define a method, so that
503
- # the blocks could return values.
504
- self.instance_eval(&block)
505
500
  else
506
- call_provider(value)
501
+ block = self.class.value_option(name, :block)
502
+ if block
503
+ # FIXME It'd be better here to define a method, so that
504
+ # the blocks could return values.
505
+ self.instance_eval(&block)
506
+ else
507
+ call_provider(value)
508
+ end
507
509
  end
508
510
  end
509
511
 
@@ -585,7 +587,8 @@ class Puppet::Property < Puppet::Parameter
585
587
  # @api private
586
588
  #
587
589
  def validate_features_per_value(value)
588
- if features = self.class.value_option(self.class.value_name(value), :required_features)
590
+ features = self.class.value_option(self.class.value_name(value), :required_features)
591
+ if features
589
592
  features = Array(features)
590
593
  needed_features = features.collect { |f| f.to_s }.join(", ")
591
594
  unless provider.satisfies?(features)
@@ -77,7 +77,8 @@ class Puppet::Property::Ensure < Puppet::Property
77
77
  # to get checked, which means that those other properties do not have
78
78
  # @is values set. This seems to be the source of quite a few bugs,
79
79
  # although they're mostly logging bugs, not functional ones.
80
- if prov = @resource.provider and prov.respond_to?(:exists?)
80
+ prov = @resource.provider
81
+ if prov && prov.respond_to?(:exists?)
81
82
  result = prov.exists?
82
83
  elsif @resource.respond_to?(:exists?)
83
84
  result = @resource.exists?
@@ -107,7 +107,8 @@ module Puppet
107
107
  #
108
108
  def retrieve
109
109
  #ok, some 'convention' if the keyvalue property is named properties, provider should implement a properties method
110
- if key_hash = provider.send(name) and key_hash != :absent
110
+ key_hash = provider.send(name) if provider
111
+ if key_hash && key_hash != :absent
111
112
  return key_hash
112
113
  else
113
114
  return :absent
@@ -45,7 +45,8 @@ module Puppet
45
45
 
46
46
  def retrieve
47
47
  #ok, some 'convention' if the list property is named groups, provider should implement a groups method
48
- if provider and tmp = provider.send(name) and tmp != :absent
48
+ tmp = provider.send(name) if provider
49
+ if tmp && tmp != :absent
49
50
  return tmp.split(delimiter)
50
51
  else
51
52
  return :absent
@@ -138,11 +138,10 @@ class Puppet::Provider
138
138
  def self.command(name)
139
139
  name = name.intern
140
140
 
141
- if defined?(@commands) and command = @commands[name]
142
- # nothing
143
- elsif superclass.respond_to? :command and command = superclass.command(name)
144
- # nothing
145
- else
141
+ command = @commands[name] if defined?(@commands)
142
+ command = superclass.command(name) if !command && superclass.respond_to?(:command)
143
+
144
+ unless command
146
145
  raise Puppet::DevError, _("No command %{command} defined for provider %{provider}") % { command: name, provider: self.name }
147
146
  end
148
147
 
@@ -466,11 +465,13 @@ class Puppet::Provider
466
465
  if param.is_a?(Class)
467
466
  klass = param
468
467
  else
469
- unless klass = resource_type.attrclass(param)
468
+ klass = resource_type.attrclass(param)
469
+ unless klass
470
470
  raise Puppet::DevError, _("'%{parameter_name}' is not a valid parameter for %{resource_type}") % { parameter_name: param, resource_type: resource_type.name }
471
471
  end
472
472
  end
473
- return true unless features = klass.required_features
473
+ features = klass.required_features
474
+ return true unless features
474
475
 
475
476
  !!satisfies?(*features)
476
477
  end
@@ -546,7 +547,8 @@ class Puppet::Provider
546
547
  # @raise [Puppet::DevError] if no resource is set, or no name defined.
547
548
  #
548
549
  def name
549
- if n = @property_hash[:name]
550
+ n = @property_hash[:name]
551
+ if n
550
552
  return n
551
553
  elsif self.resource
552
554
  resource.name
@@ -82,11 +82,14 @@ class Puppet::Provider::Exec < Puppet::Provider
82
82
  def extractexe(command)
83
83
  if command.is_a? Array
84
84
  command.first
85
- elsif match = /^"([^"]+)"|^'([^']+)'/.match(command)
86
- # extract whichever of the two sides matched the content.
87
- match[1] or match[2]
88
85
  else
89
- command.split(/ /)[0]
86
+ match = /^"([^"]+)"|^'([^']+)'/.match(command)
87
+ if match
88
+ # extract whichever of the two sides matched the content.
89
+ match[1] or match[2]
90
+ else
91
+ command.split(/ /)[0]
92
+ end
90
93
  end
91
94
  end
92
95
 
@@ -53,7 +53,8 @@ Puppet::Type.type(:file).provide :posix do
53
53
  end
54
54
 
55
55
  def owner
56
- unless stat = resource.stat
56
+ stat = resource.stat
57
+ unless stat
57
58
  return :absent
58
59
  end
59
60
 
@@ -86,7 +87,8 @@ Puppet::Type.type(:file).provide :posix do
86
87
  end
87
88
 
88
89
  def group
89
- return :absent unless stat = resource.stat
90
+ stat = resource.stat
91
+ return :absent unless stat
90
92
 
91
93
  currentvalue = stat.gid
92
94
 
@@ -117,7 +119,8 @@ Puppet::Type.type(:file).provide :posix do
117
119
  end
118
120
 
119
121
  def mode
120
- if stat = resource.stat
122
+ stat = resource.stat
123
+ if stat
121
124
  return (stat.mode & 007777).to_s(8).rjust(4, '0')
122
125
  else
123
126
  return :absent
@@ -73,7 +73,8 @@ Puppet::Type.type(:group).provide :groupadd, :parent => Puppet::Provider::NameSe
73
73
  cmd = [command(:add)]
74
74
  end
75
75
 
76
- if gid = @resource.should(:gid)
76
+ gid = @resource.should(:gid)
77
+ if gid
77
78
  unless gid == :absent
78
79
  cmd << flag(:gid) << gid
79
80
  end
@@ -24,9 +24,11 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do
24
24
  provider = self
25
25
  manager.generates(:gidNumber).with do
26
26
  largest = 500
27
- if existing = provider.manager.search
28
- existing.each do |hash|
29
- next unless value = hash[:gid]
27
+ existing = provider.manager.search
28
+ if existing
29
+ existing.each do |hash|
30
+ value = hash[:gid]
31
+ next unless value
30
32
  num = value[0].to_i
31
33
  largest = num if num > largest
32
34
  end
@@ -36,7 +38,8 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do
36
38
 
37
39
  # Convert a group name to an id.
38
40
  def self.name2id(group)
39
- return nil unless result = manager.search("cn=#{group}") and result.length > 0
41
+ result = manager.search("cn=#{group}")
42
+ return nil unless result and result.length > 0
40
43
 
41
44
  # Only use the first result.
42
45
  group = result[0]
@@ -18,13 +18,15 @@ Puppet::Type.type(:group).provide :pw, :parent => Puppet::Provider::NameService:
18
18
  def addcmd
19
19
  cmd = [command(:pw), "groupadd", @resource[:name]]
20
20
 
21
- if gid = @resource.should(:gid)
21
+ gid = @resource.should(:gid)
22
+ if gid
22
23
  unless gid == :absent
23
24
  cmd << flag(:gid) << gid
24
25
  end
25
26
  end
26
27
 
27
- if members = @resource.should(:members)
28
+ members = @resource.should(:members)
29
+ if members
28
30
  unless members == :absent
29
31
  if members.is_a?(Array)
30
32
  members = members.join(",")
@@ -10,7 +10,8 @@ class Puppet::Provider::Ldap < Puppet::Provider
10
10
 
11
11
  # Look up all instances at our location. Yay.
12
12
  def self.instances
13
- return [] unless list = manager.search
13
+ list = manager.search
14
+ return [] unless list
14
15
 
15
16
  list.collect { |entry| new(entry) }
16
17
  end
@@ -29,7 +30,8 @@ class Puppet::Provider::Ldap < Puppet::Provider
29
30
  # Query all of our resources from ldap.
30
31
  def self.prefetch(resources)
31
32
  resources.each do |name, resource|
32
- if result = manager.find(name)
33
+ result = manager.find(name)
34
+ if result
33
35
  result[:ensure] = :present
34
36
  resource.provider = new(result)
35
37
  else
@@ -45,7 +47,8 @@ class Puppet::Provider::Ldap < Puppet::Provider
45
47
  def create
46
48
  @property_hash[:ensure] = :present
47
49
  self.class.resource_type.validproperties.each do |property|
48
- if val = resource.should(property)
50
+ val = resource.should(property)
51
+ if val
49
52
  if property.to_s == 'gid'
50
53
  self.gid = val
51
54
  else
@@ -126,7 +129,8 @@ class Puppet::Provider::Ldap < Puppet::Provider
126
129
  # LAK:NOTE This is normally not used, because we rely on prefetching.
127
130
  def query
128
131
  # Use the module function.
129
- unless attributes = manager.find(name)
132
+ attributes = manager.find(name)
133
+ unless attributes
130
134
  @ldap_properties = {}
131
135
  return nil
132
136
  end
@@ -26,7 +26,7 @@ class Puppet::Provider::NameService < Puppet::Provider
26
26
  objects = []
27
27
  begin
28
28
  method = Puppet::Etc.method(:"get#{section}ent")
29
- while ent = method.call
29
+ while ent = method.call #rubocop:disable Lint/AssignmentInCondition
30
30
  objects << new(:name => ent.name, :canonical_name => ent.canonical_name, :ensure => :present)
31
31
  end
32
32
  ensure
@@ -61,7 +61,7 @@ class Puppet::Provider::NameService < Puppet::Provider
61
61
  names = []
62
62
  Puppet::Etc.send("set#{section()}ent")
63
63
  begin
64
- while ent = Puppet::Etc.send("get#{section()}ent")
64
+ while ent = Puppet::Etc.send("get#{section()}ent") #rubocop:disable Lint/AssignmentInCondition
65
65
  names << ent.name
66
66
  yield ent.name if block_given?
67
67
  end
@@ -124,7 +124,8 @@ class Puppet::Provider::NameService < Puppet::Provider
124
124
  if id_generators[@resource.class.name] == field
125
125
  return self.class.autogen_id(field, @resource.class.name)
126
126
  else
127
- if value = self.class.autogen_default(field)
127
+ value = self.class.autogen_default(field)
128
+ if value
128
129
  return value
129
130
  elsif respond_to?("autogen_#{field}")
130
131
  return send("autogen_#{field}")
@@ -214,7 +215,8 @@ class Puppet::Provider::NameService < Puppet::Provider
214
215
  end
215
216
 
216
217
  def munge(name, value)
217
- if block = self.class.option(name, :munge) and block.is_a? Proc
218
+ block = self.class.option(name, :munge)
219
+ if block and block.is_a? Proc
218
220
  block.call(value)
219
221
  else
220
222
  value
@@ -222,7 +224,8 @@ class Puppet::Provider::NameService < Puppet::Provider
222
224
  end
223
225
 
224
226
  def unmunge(name, value)
225
- if block = self.class.option(name, :unmunge) and block.is_a? Proc
227
+ block = self.class.option(name, :unmunge)
228
+ if block and block.is_a? Proc
226
229
  block.call(value)
227
230
  else
228
231
  value