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
@@ -46,10 +46,13 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
46
46
  def self.filetype=(type)
47
47
  if type.is_a?(Class)
48
48
  @filetype = type
49
- elsif klass = Puppet::Util::FileType.filetype(type)
50
- @filetype = klass
51
49
  else
52
- raise ArgumentError, _("Invalid filetype %{type}") % { type: type }
50
+ klass = Puppet::Util::FileType.filetype(type)
51
+ if klass
52
+ @filetype = klass
53
+ else
54
+ raise ArgumentError, _("Invalid filetype %{type}") % { type: type }
55
+ end
53
56
  end
54
57
  end
55
58
 
@@ -240,7 +243,8 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
240
243
  if (resource = resource_for_record(record, resources))
241
244
  resource.provider = new(record)
242
245
  elsif respond_to?(:match)
243
- if resource = match(record, matchers)
246
+ resource = match(record, matchers)
247
+ if resource
244
248
  matchers.delete(resource.title)
245
249
  record[:name] = resource[:name]
246
250
  resource.provider = new(record)
@@ -380,7 +384,8 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
380
384
  # Lastly, check the file from any resource instances
381
385
  if resources
382
386
  resources.each do |name, resource|
383
- if value = resource.should(:target)
387
+ value = resource.should(:target)
388
+ if value
384
389
  targets << value
385
390
  end
386
391
  end
@@ -414,7 +419,8 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
414
419
 
415
420
  def create
416
421
  @resource.class.validproperties.each do |property|
417
- if value = @resource.should(property)
422
+ value = @resource.should(property)
423
+ if value
418
424
  @property_hash[property] = value
419
425
  end
420
426
  end
@@ -472,7 +478,8 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
472
478
 
473
479
  # Mark both the resource and provider target as modified.
474
480
  def mark_target_modified
475
- if defined?(@resource) and restarget = @resource.should(:target) and restarget != @property_hash[:target]
481
+ restarget = @resource.should(:target) if defined?(@resource)
482
+ if restarget && restarget != @property_hash[:target]
476
483
  self.class.modified(restarget)
477
484
  end
478
485
  self.class.modified(@property_hash[:target]) if @property_hash[:target] != :absent and @property_hash[:target]
@@ -76,11 +76,14 @@ Puppet::Type.type(:service).provide :base, :parent => :service do
76
76
  else
77
77
  return :stopped
78
78
  end
79
- elsif pid = getpid
80
- self.debug "PID is #{pid}"
81
- return :running
82
79
  else
83
- return :stopped
80
+ pid = getpid
81
+ if pid
82
+ self.debug "PID is #{pid}"
83
+ return :running
84
+ else
85
+ return :stopped
86
+ end
84
87
  end
85
88
  end
86
89
 
@@ -92,7 +92,8 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
92
92
  # clear out our cache when we're done.
93
93
  def self.prefetch(resources)
94
94
  instances.each do |prov|
95
- if resource = resources[prov.name]
95
+ resource = resources[prov.name]
96
+ if resource
96
97
  resource.provider = prov
97
98
  end
98
99
  end
@@ -316,7 +317,8 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
316
317
  _, job_plist = plist_from_label(resource[:name])
317
318
  job_plist_disabled = job_plist["Disabled"] if job_plist.has_key?("Disabled")
318
319
 
319
- if FileTest.file?(self.class.launchd_overrides) and overrides = self.class.read_overrides
320
+ overrides = self.class.read_overrides if FileTest.file?(self.class.launchd_overrides)
321
+ if overrides
320
322
  if overrides.has_key?(resource[:name])
321
323
  if self.class.get_os_version < 14
322
324
  overrides_disabled = overrides[resource[:name]]["Disabled"] if overrides[resource[:name]].has_key?("Disabled")
@@ -31,7 +31,8 @@ Puppet::Type.type(:service).provide :service do
31
31
 
32
32
  # Use either a specified command or the default for our provider.
33
33
  def ucommand(type, fof = true)
34
- if c = @resource[type]
34
+ c = @resource[type]
35
+ if c
35
36
  cmd = [c]
36
37
  else
37
38
  cmd = [send("#{type}cmd")].flatten
@@ -76,14 +76,17 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
76
76
  # network-interface (lo) start/running
77
77
  # network-interface (eth0) start/running
78
78
  # network-interface-security start/running
79
- name = \
80
- if matcher = line.match(/^(network-interface)\s\(([^\)]+)\)/)
81
- "#{matcher[1]} INTERFACE=#{matcher[2]}"
82
- elsif matcher = line.match(/^(network-interface-security)\s\(([^\)]+)\)/)
83
- "#{matcher[1]} JOB=#{matcher[2]}"
84
- else
85
- line.split.first
86
- end
79
+ matcher = line.match(/^(network-interface)\s\(([^\)]+)\)/)
80
+ name = if matcher
81
+ "#{matcher[1]} INTERFACE=#{matcher[2]}"
82
+ else
83
+ matcher = line.match(/^(network-interface-security)\s\(([^\)]+)\)/)
84
+ if matcher
85
+ "#{matcher[1]} JOB=#{matcher[2]}"
86
+ else
87
+ line.split.first
88
+ end
89
+ end
87
90
  instances << new(:name => name)
88
91
  }
89
92
  }
@@ -71,7 +71,8 @@ Puppet::Type.type(:user).provide :directoryservice do
71
71
  # takes time and front-loads your Puppet run.
72
72
  def self.prefetch(resources)
73
73
  instances.each do |prov|
74
- if resource = resources[prov.name]
74
+ resource = resources[prov.name]
75
+ if resource
75
76
  resource.provider = prov
76
77
  end
77
78
  end
@@ -46,7 +46,7 @@ Puppet::Type.type(:user).provide :hpuxuseradd, :parent => :useradd do
46
46
  def password
47
47
  # Password management routine for trusted and non-trusted systems
48
48
  #temp=""
49
- while ent = Etc.getpwent() do
49
+ while ent = Etc.getpwent() do # rubocop:disable Lint/AssignmentInCondition
50
50
  if ent.name == resource.name
51
51
  temp=ent.name
52
52
  break
@@ -34,9 +34,11 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
34
34
  provider = self
35
35
  manager.generates(:uidNumber).with do
36
36
  largest = 500
37
- if existing = provider.manager.search
37
+ existing = provider.manager.search
38
+ if existing
38
39
  existing.each do |hash|
39
- next unless value = hash[:uid]
40
+ value = hash[:uid]
41
+ next unless value
40
42
  num = value[0].to_i
41
43
  largest = num if num > largest
42
44
  end
@@ -56,7 +58,8 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
56
58
  # We want to cache the current result, so we know if we
57
59
  # have to remove old values.
58
60
  unless @property_hash[:groups]
59
- unless result = group_manager.search("memberUid=#{name}")
61
+ result = group_manager.search("memberUid=#{name}")
62
+ unless result
60
63
  return @property_hash[:groups] = :absent
61
64
  end
62
65
 
@@ -88,7 +91,8 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
88
91
  end
89
92
 
90
93
  modes.each do |group, form|
91
- self.fail "Could not find ldap group #{group}" unless ldap_group = group_manager.find(group)
94
+ ldap_group = group_manager.find(group)
95
+ self.fail "Could not find ldap group #{group}" unless ldap_group
92
96
 
93
97
  current = ldap_group[:members]
94
98
 
@@ -39,7 +39,8 @@ Puppet::Type.type(:user).provide :openbsd, :parent => :useradd do
39
39
  [:expiry, :password, :loginclass].each do |shadow_property|
40
40
  define_method(shadow_property) do
41
41
  if Puppet.features.libshadow?
42
- if ent = Shadow::Passwd.getspnam(@resource.name)
42
+ ent = Shadow::Passwd.getspnam(@resource.name)
43
+ if ent
43
44
  method = self.class.option(shadow_property, :method)
44
45
  # ruby-shadow may not be new enough (< 2.4.1) and therefore lack the
45
46
  # sp_loginclass field.
@@ -31,7 +31,8 @@ Puppet::Type.type(:user).provide :pw, :parent => Puppet::Provider::NameService::
31
31
  cmd = [command(:pw), "useradd", @resource[:name]]
32
32
  @resource.class.validproperties.each do |property|
33
33
  next if property == :ensure or property == :password
34
- if value = @resource.should(property) and value != ""
34
+ value = @resource.should(property)
35
+ if value and value != ""
35
36
  cmd << flag(property) << munge(property,value)
36
37
  end
37
38
  end
@@ -53,7 +53,8 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
53
53
  # 1680 Now you can set the hashed passwords on solaris:lib/puppet/provider/user/user_role_add.rb
54
54
  # the value needs to be quoted, mostly because -c might
55
55
  # have spaces in it
56
- if value = @resource.should(property) and value != ""
56
+ value = @resource.should(property)
57
+ if value && value != ""
57
58
  if property == :keys
58
59
  cmd += build_keys_cmd(value)
59
60
  else
@@ -99,7 +100,8 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
99
100
  run(transition("normal"), "transition role to")
100
101
  else
101
102
  run(addcmd, "create")
102
- if cmd = passcmd
103
+ cmd = passcmd
104
+ if cmd
103
105
  run(cmd, "change password policy for")
104
106
  end
105
107
  end
@@ -151,9 +151,11 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
151
151
  next if property_manages_password_age?(property)
152
152
  next if (property == :groups) && @resource.forcelocal?
153
153
  next if (property == :expiry) && @resource.forcelocal?
154
- # the value needs to be quoted, mostly because -c might
155
- # have spaces in it
156
- if (value = @resource.should(property)) && (value != "")
154
+
155
+ value = @resource.should(property)
156
+ if value && value != ""
157
+ # the value needs to be quoted, mostly because -c might
158
+ # have spaces in it
157
159
  cmd << flag(property) << munge(property, value)
158
160
  end
159
161
  end
@@ -228,7 +230,8 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
228
230
  [:expiry, :password_min_age, :password_max_age, :password_warn_days, :password].each do |shadow_property|
229
231
  define_method(shadow_property) do
230
232
  if Puppet.features.libshadow?
231
- if ent = Shadow::Passwd.getspnam(@canonical_name)
233
+ ent = Shadow::Passwd.getspnam(@canonical_name)
234
+ if ent
232
235
  method = self.class.option(shadow_property, :method)
233
236
  return unmunge(shadow_property, ent.send(method))
234
237
  end
@@ -32,7 +32,6 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider
32
32
 
33
33
  table_data = {}
34
34
 
35
- functional = false
36
35
  notes = []
37
36
  default = type.defaultprovider ? type.defaultprovider.name : 'none'
38
37
  type.providers.sort { |a,b| a.to_s <=> b.to_s }.each do |pname|
@@ -41,10 +40,10 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider
41
40
  provider = type.provider(pname)
42
41
 
43
42
  # Add the suitability note
44
- if missing = provider.suitable?(false) and missing.empty?
43
+ missing = provider.suitable?(false)
44
+ if missing && missing.empty?
45
45
  data << "*X*"
46
46
  suit = true
47
- functional = true
48
47
  else
49
48
  data << "[#{count}]_" # A pointer to the appropriate footnote
50
49
  suit = false
@@ -63,7 +63,8 @@ Puppet::Util::Reference.newreference :type, :doc => "All Puppet resource types a
63
63
  str << scrub(type.doc) + "\n\n"
64
64
 
65
65
  # Handle the feature docs.
66
- if featuredocs = type.featuredocs
66
+ featuredocs = type.featuredocs
67
+ if featuredocs
67
68
  str << markdown_header("Features", 4)
68
69
  str << featuredocs
69
70
  end
@@ -79,7 +80,8 @@ Puppet::Util::Reference.newreference :type, :doc => "All Puppet resource types a
79
80
 
80
81
  raise _("Could not retrieve property %{sname} on type %{type_name}") % { sname: sname, type_name: type.name } unless property
81
82
 
82
- unless doc = property.doc
83
+ doc = property.doc
84
+ unless doc
83
85
  $stderr.puts _("No docs for %{type}[%{sname}]") % { type: type, sname: sname }
84
86
  next
85
87
  end
@@ -19,12 +19,8 @@ class Puppet::Relationship
19
19
  target = data['target']
20
20
 
21
21
  args = {}
22
- if event = data["event"]
23
- args[:event] = :"#{event}"
24
- end
25
- if callback = data["callback"]
26
- args[:callback] = :"#{callback}"
27
- end
22
+ args[:event] = :"#{data['event']}" if data["event"]
23
+ args[:callback] = :"#{data['callback']}" if data["callback"]
28
24
 
29
25
  new(source, target, args)
30
26
  end
@@ -40,9 +36,8 @@ class Puppet::Relationship
40
36
 
41
37
  options = (options || {}).inject({}) { |h,a| h[a[0].to_sym] = a[1]; h }
42
38
  [:callback, :event].each do |option|
43
- if value = options[option]
44
- send(option.to_s + "=", value)
45
- end
39
+ value = options[option]
40
+ send(option.to_s + "=", value) if value
46
41
  end
47
42
  end
48
43
 
@@ -44,11 +44,14 @@ class Puppet::Resource
44
44
  end
45
45
 
46
46
  def initialize_from_hash(data)
47
- raise ArgumentError, _('No resource type provided in serialized data') unless type = data['type']
48
- raise ArgumentError, _('No resource title provided in serialized data') unless title = data['title']
47
+ type = data['type']
48
+ raise ArgumentError, _('No resource type provided in serialized data') unless type
49
+ title = data['title']
50
+ raise ArgumentError, _('No resource title provided in serialized data') unless title
49
51
  @type, @title = self.class.type_and_title(type, title)
50
52
 
51
- if params = data['parameters']
53
+ params = data['parameters']
54
+ if params
52
55
  params = Puppet::Pops::Serialization::FromDataConverter.convert(params)
53
56
  @parameters = {}
54
57
  params.each { |param, value| self[param] = value }
@@ -56,13 +59,15 @@ class Puppet::Resource
56
59
  @parameters = EMPTY_HASH
57
60
  end
58
61
 
59
- if sensitives = data['sensitive_parameters']
62
+ sensitives = data['sensitive_parameters']
63
+ if sensitives
60
64
  @sensitive_parameters = sensitives.map(&:to_sym)
61
65
  else
62
66
  @sensitive_parameters = EMPTY_ARRAY
63
67
  end
64
68
 
65
- if tags = data['tags']
69
+ tags = data['tags']
70
+ if tags
66
71
  tag(*tags)
67
72
  end
68
73
 
@@ -554,7 +559,8 @@ class Puppet::Resource
554
559
  arg_types = resource_type.argument_types
555
560
  # Parameters is a map from name, to parameter, and the parameter again has name and value
556
561
  parameters.each do |name, value|
557
- next unless t = arg_types[name.to_s] # untyped, and parameters are symbols here (aargh, strings in the type)
562
+ t = arg_types[name.to_s] # untyped, and parameters are symbols here (aargh, strings in the type)
563
+ next unless t
558
564
  unless Puppet::Pops::Types::TypeCalculator.instance?(t, value.value)
559
565
  inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value.value)
560
566
  actual = inferred_type.generalize()
@@ -657,8 +663,9 @@ class Puppet::Resource
657
663
  h = {}
658
664
  type = resource_type
659
665
  if type.respond_to?(:title_patterns) && !type.title_patterns.nil?
660
- type.title_patterns.each { |regexp, symbols_and_lambdas|
661
- if captures = regexp.match(title.to_s)
666
+ type.title_patterns.each do |regexp, symbols_and_lambdas|
667
+ captures = regexp.match(title.to_s)
668
+ if captures
662
669
  symbols_and_lambdas.zip(captures[1..-1]).each do |symbol_and_lambda,capture|
663
670
  symbol, proc = symbol_and_lambda
664
671
  # Many types pass "identity" as the proc; we might as well give
@@ -677,7 +684,7 @@ class Puppet::Resource
677
684
  end
678
685
  return h
679
686
  end
680
- }
687
+ end
681
688
  # If we've gotten this far, then none of the provided title patterns
682
689
  # matched. Since there's no way to determine the title then the
683
690
  # resource should fail here.
@@ -38,14 +38,17 @@ module Puppet::Resource::CapabilityFinder
38
38
  Puppet.debug "Could not find capability resource #{cap} in PuppetDB"
39
39
  elsif resources.size == 1
40
40
  resource_hash = resources.first
41
- elsif code_id_resource = disambiguate_by_code_id(environment, code_id, cap)
42
- resource_hash = code_id_resource
43
41
  else
44
- #TRANSLATOR PuppetDB is a product name and should not be translated
45
- message = _("Unexpected response from PuppetDB when looking up %{capability}:") % { capability: cap }
46
- message += "\n" + _("expected exactly one resource but got %{count};") % { count: resources.size }
47
- message += "\n" + _("returned data is:\n%{resources}") % { resources: resources.inspect }
48
- raise Puppet::DevError, message
42
+ code_id_resource = disambiguate_by_code_id(environment, code_id, cap)
43
+ if code_id_resource
44
+ resource_hash = code_id_resource
45
+ else
46
+ #TRANSLATOR PuppetDB is a product name and should not be translated
47
+ message = _("Unexpected response from PuppetDB when looking up %{capability}:") % { capability: cap }
48
+ message += "\n" + _("expected exactly one resource but got %{count};") % { count: resources.size }
49
+ message += "\n" + _("returned data is:\n%{resources}") % { resources: resources.inspect }
50
+ raise Puppet::DevError, message
51
+ end
49
52
  end
50
53
 
51
54
  if resource_hash
@@ -138,7 +141,8 @@ module Puppet::Resource::CapabilityFinder
138
141
  real_type.parameters.each do |param|
139
142
  param = param.to_s
140
143
  next if param == 'name'
141
- if value = resource_hash['parameters'][param]
144
+ value = resource_hash['parameters'][param]
145
+ if value
142
146
  resource[param] = value
143
147
  else
144
148
  Puppet.debug "No capability value for #{resource}->#{param}"
@@ -197,7 +197,8 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
197
197
  # because sometimes an alias is created before the resource is
198
198
  # added to the catalog, so comparing inside the below if block
199
199
  # isn't sufficient.
200
- if existing = @resource_table[newref]
200
+ existing = @resource_table[newref]
201
+ if existing
201
202
  return if existing == resource
202
203
  resource_declaration = Puppet::Util::Errors.error_location(resource.file, resource.line)
203
204
  msg = if resource_declaration.empty?
@@ -286,10 +287,12 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
286
287
 
287
288
  # Create a new resource and register it in the catalog.
288
289
  def create_resource(type, options)
289
- unless klass = Puppet::Type.type(type)
290
+ klass = Puppet::Type.type(type)
291
+ unless klass
290
292
  raise ArgumentError, _("Unknown resource type %{type}") % { type: type }
291
293
  end
292
- return unless resource = klass.new(options)
294
+ resource = klass.new(options)
295
+ return unless resource
293
296
 
294
297
  add_resource(resource)
295
298
  resource
@@ -342,7 +345,8 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
342
345
  Puppet::Type.type(:schedule).mkdefaultschedules.each { |res| add_resource(res) unless resource(res.ref) }
343
346
 
344
347
  # And filebuckets
345
- if bucket = Puppet::Type.type(:filebucket).mkdefaultbucket
348
+ bucket = Puppet::Type.type(:filebucket).mkdefaultbucket
349
+ if bucket
346
350
  add_resource(bucket) unless resource(bucket.ref)
347
351
  end
348
352
  end
@@ -355,7 +359,8 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
355
359
  ref = resource.ref
356
360
  title_key = title_key_for_ref(ref)
357
361
  @resource_table.delete(title_key)
358
- if aliases = @aliases[ref]
362
+ aliases = @aliases[ref]
363
+ if aliases
359
364
  aliases.each { |res_alias| @resource_table.delete(res_alias) }
360
365
  @aliases.delete(ref)
361
366
  end
@@ -415,45 +420,36 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
415
420
  def self.from_data_hash(data)
416
421
  result = new(data['name'], Puppet::Node::Environment::NONE)
417
422
 
418
- if tags = data['tags']
419
- result.tag(*tags)
420
- end
421
-
422
- if version = data['version']
423
- result.version = version
424
- end
425
-
426
- if code_id = data['code_id']
427
- result.code_id = code_id
428
- end
429
-
430
- if catalog_uuid = data['catalog_uuid']
431
- result.catalog_uuid = catalog_uuid
432
- end
433
-
423
+ result.tag(*data['tags']) if data['tags']
424
+ result.version = data['version'] if data['version']
425
+ result.code_id = data['code_id'] if data['code_id']
426
+ result.catalog_uuid = data['catalog_uuid'] if data['catalog_uuid']
434
427
  result.catalog_format = data['catalog_format'] || 0
435
428
 
436
- if environment = data['environment']
429
+ environment = data['environment']
430
+ if environment
437
431
  result.environment = environment
438
432
  result.environment_instance = Puppet::Node::Environment.remote(environment.to_sym)
439
433
  end
440
434
 
441
- if resources = data['resources']
442
- result.add_resource(*resources.collect do |res|
435
+ result.add_resource(
436
+ *data['resources'].collect do |res|
443
437
  Puppet::Resource.from_data_hash(res)
444
- end)
445
- end
438
+ end
439
+ ) if data['resources']
446
440
 
447
- if edges = data['edges']
448
- edges.each do |edge_hash|
441
+ if data['edges']
442
+ data['edges'].each do |edge_hash|
449
443
  edge = Puppet::Relationship.from_data_hash(edge_hash)
450
- unless source = result.resource(edge.source)
444
+ source = result.resource(edge.source)
445
+ unless source
451
446
  raise ArgumentError, _("Could not intern from data: Could not find relationship source %{source} for %{target}") %
452
447
  { source: edge.source.inspect, target: edge.target.to_s }
453
448
  end
454
449
  edge.source = source
455
450
 
456
- unless target = result.resource(edge.target)
451
+ target = result.resource(edge.target)
452
+ unless target
457
453
  raise ArgumentError, _("Could not intern from data: Could not find relationship target %{target} for %{source}") %
458
454
  { target: edge.target.inspect, source: edge.source.to_s }
459
455
  end
@@ -463,15 +459,12 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
463
459
  end
464
460
  end
465
461
 
466
- if classes = data['classes']
467
- result.add_class(*classes)
468
- end
462
+ result.add_class(*data['classes']) if data['classes']
469
463
 
470
- if metadata = data['metadata']
471
- result.metadata = metadata.inject({}) { |h, (k, v)| h[k] = Puppet::FileServing::Metadata.from_data_hash(v); h }
472
- end
464
+ result.metadata = data['metadata'].inject({}) { |h, (k, v)| h[k] = Puppet::FileServing::Metadata.from_data_hash(v); h } if data['metadata']
473
465
 
474
- if recursive_metadata = data['recursive_metadata']
466
+ recursive_metadata = data['recursive_metadata']
467
+ if recursive_metadata
475
468
  result.recursive_metadata = recursive_metadata.inject({}) do |h, (title, source_to_meta_hash)|
476
469
  h[title] = source_to_meta_hash.inject({}) do |inner_h, (source, metas)|
477
470
  inner_h[source] = metas.map {|meta| Puppet::FileServing::Metadata.from_data_hash(meta)}
@@ -592,7 +585,8 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
592
585
  # Verify that the given resource isn't declared elsewhere.
593
586
  def fail_on_duplicate_type_and_title(resource, title_key)
594
587
  # Short-circuit the common case,
595
- return unless existing_resource = @resource_table[title_key]
588
+ existing_resource = @resource_table[title_key]
589
+ return unless existing_resource
596
590
 
597
591
  # If we've gotten this far, it's a real conflict
598
592
  error_location_str = Puppet::Util::Errors.error_location(existing_resource.file, existing_resource.line)
@@ -646,11 +640,13 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
646
640
  next if virtual_not_exported?(edge.target)
647
641
  next if block_given? and yield edge.target
648
642
 
649
- unless source = map[edge.source.ref]
643
+ source = map[edge.source.ref]
644
+ unless source
650
645
  raise Puppet::DevError, _("Could not find resource %{resource} when converting %{message} resources") % { resource: edge.source.ref, message: message }
651
646
  end
652
647
 
653
- unless target = map[edge.target.ref]
648
+ target = map[edge.target.ref]
649
+ unless target
654
650
  raise Puppet::DevError, _("Could not find resource %{resource} when converting %{message} resources") % { resource: edge.target.ref, message: message }
655
651
  end
656
652