puppet 6.6.0-x64-mingw32 → 6.7.0-x64-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
@@ -6,7 +6,8 @@ module Puppet
6
6
 
7
7
  def retrieve
8
8
  current_value = :absent
9
- if stat = @resource.stat
9
+ stat = @resource.stat
10
+ if stat
10
11
  current_value = stat.ctime
11
12
  end
12
13
  current_value
@@ -71,7 +71,8 @@ module Puppet
71
71
  end
72
72
 
73
73
  def retrieve_checksum(resource)
74
- return :absent unless stat = resource.stat
74
+ stat = resource.stat
75
+ return :absent unless stat
75
76
  ftype = stat.ftype
76
77
  # Don't even try to manage the content on directories or links
77
78
  return nil if ["directory","link"].include?(ftype)
@@ -62,9 +62,8 @@ module Puppet
62
62
 
63
63
  newvalue(:file, :event => :file_created) do
64
64
  # Make sure we're not managing the content some other way
65
- if property = @resource.property(:content)
66
- property.sync
67
- elsif property = @resource.property(:checksum_value)
65
+ property = @resource.property(:content) || @resource.property(:checksum_value)
66
+ if property
68
67
  property.sync
69
68
  else
70
69
  @resource.write
@@ -99,7 +98,8 @@ module Puppet
99
98
 
100
99
 
101
100
  newvalue(:link, :event => :link_created, :required_features => :manages_symlinks) do
102
- fail "Cannot create a symlink without a target" unless property = resource.property(:target)
101
+ property = resource.property(:target)
102
+ fail "Cannot create a symlink without a target" unless property
103
103
  property.retrieve
104
104
  property.mklink
105
105
  end
@@ -120,11 +120,13 @@ module Puppet
120
120
  def change_to_s(currentvalue, newvalue)
121
121
  return super unless [:file, :present].include?(newvalue)
122
122
 
123
- return super unless property = @resource.property(:content)
123
+ property = @resource.property(:content)
124
+ return super unless property
124
125
 
125
126
  # We know that content is out of sync if we're here, because
126
127
  # it's essentially equivalent to 'ensure' in the transaction.
127
- if source = @resource.parameter(:source)
128
+ source = @resource.parameter(:source)
129
+ if source
128
130
  should = source.checksum
129
131
  else
130
132
  should = property.should
@@ -166,7 +168,8 @@ module Puppet
166
168
  end
167
169
 
168
170
  def retrieve
169
- if stat = @resource.stat
171
+ stat = @resource.stat
172
+ if stat
170
173
  return stat.ftype.intern
171
174
  else
172
175
  if self.should == :false
@@ -121,7 +121,8 @@ module Puppet
121
121
  return false if munged_mode.nil?
122
122
  currentvalue = munged_mode
123
123
  end
124
- if stat = @resource.stat and stat.ftype == "link" and @resource[:links] != :follow
124
+ stat = @resource.stat
125
+ if stat && stat.ftype == "link" && @resource[:links] != :follow
125
126
  self.debug _("Not managing symlink mode")
126
127
  return true
127
128
  else
@@ -5,7 +5,8 @@ module Puppet
5
5
 
6
6
  def retrieve
7
7
  current_value = :absent
8
- if stat = @resource.stat
8
+ stat = @resource.stat
9
+ if stat
9
10
  current_value = stat.mtime
10
11
  end
11
12
  current_value
@@ -42,7 +42,8 @@ module Puppet
42
42
  return nil
43
43
  end
44
44
 
45
- unless context = self.get_selinux_default_context(@resource[:path])
45
+ context = self.get_selinux_default_context(@resource[:path])
46
+ unless context
46
47
  return nil
47
48
  end
48
49
 
@@ -134,7 +134,8 @@ module Puppet
134
134
  return @content if @content
135
135
  raise Puppet::DevError, _("No source for content was stored with the metadata") unless metadata.source
136
136
 
137
- unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source, :environment => resource.catalog.environment_instance, :links => resource[:links])
137
+ tmp = Puppet::FileServing::Content.indirection.find(metadata.source, :environment => resource.catalog.environment_instance, :links => resource[:links])
138
+ unless tmp
138
139
  self.fail "Could not find any content at %s" % metadata.source
139
140
  end
140
141
  @content = tmp.content
@@ -183,12 +184,9 @@ module Puppet
183
184
  # if we can't find data about this host, and fail if there are any
184
185
  # problems in our query.
185
186
  def metadata
187
+ @metadata ||= resource.catalog.metadata[resource.title]
186
188
  return @metadata if @metadata
187
189
 
188
- if @metadata = resource.catalog.metadata[resource.title]
189
- return @metadata
190
- end
191
-
192
190
  return nil unless value
193
191
  value.each do |source|
194
192
  begin
@@ -199,7 +197,8 @@ module Puppet
199
197
  :source_permissions => resource[:source_permissions]
200
198
  }
201
199
 
202
- if data = Puppet::FileServing::Metadata.indirection.find(source, options)
200
+ data = Puppet::FileServing::Metadata.indirection.find(source, options)
201
+ if data
203
202
  @metadata = data
204
203
  @metadata.source = source
205
204
  break
@@ -286,7 +285,7 @@ module Puppet
286
285
 
287
286
  def chunk_file_from_disk
288
287
  File.open(full_path, "rb") do |src|
289
- while chunk = src.read(8192)
288
+ while chunk = src.read(8192) #rubocop:disable Lint/AssignmentInCondition
290
289
  yield chunk
291
290
  end
292
291
  end
@@ -72,7 +72,8 @@ module Puppet
72
72
 
73
73
 
74
74
  def retrieve
75
- if stat = @resource.stat
75
+ stat = @resource.stat
76
+ if stat
76
77
  if stat.ftype == "link"
77
78
  return Puppet::FileSystem.readlink(@resource[:path])
78
79
  else
@@ -5,7 +5,8 @@ module Puppet
5
5
 
6
6
  def retrieve
7
7
  current_value = :absent
8
- if stat = @resource.stat
8
+ stat = @resource.stat
9
+ if stat
9
10
  current_value = stat.ftype
10
11
  end
11
12
  current_value
@@ -544,12 +544,14 @@ module Puppet
544
544
  autorequire(:file) do
545
545
  autos = []
546
546
  [:responsefile, :adminfile].each { |param|
547
- if val = self[param]
547
+ val = self[param]
548
+ if val
548
549
  autos << val
549
550
  end
550
551
  }
551
552
 
552
- if source = self[:source] and absolute_path?(source)
553
+ source = self[:source]
554
+ if source && absolute_path?(source)
553
555
  autos << source
554
556
  end
555
557
  autos
@@ -557,7 +559,8 @@ module Puppet
557
559
 
558
560
  # This only exists for testing.
559
561
  def clear
560
- if obj = @parameters[:ensure]
562
+ obj = @parameters[:ensure]
563
+ if obj
561
564
  obj.latest = nil
562
565
  end
563
566
  end
@@ -132,7 +132,8 @@ Puppet::Type.newtype(:resources) do
132
132
 
133
133
  def resource_type
134
134
  unless defined?(@resource_type)
135
- unless type = Puppet::Type.type(self[:name])
135
+ type = Puppet::Type.type(self[:name])
136
+ unless type
136
137
  raise Puppet::DevError, _("Could not find resource type")
137
138
  end
138
139
  @resource_type = type
@@ -115,7 +115,8 @@ module Puppet
115
115
  def sync
116
116
  event = super()
117
117
 
118
- if property = @resource.property(:enable)
118
+ property = @resource.property(:enable)
119
+ if property
119
120
  val = property.retrieve
120
121
  property.sync unless property.safe_insync?(val)
121
122
  end
@@ -118,7 +118,8 @@ Puppet::Type.newtype(:tidy) do
118
118
  }
119
119
 
120
120
  def convert(unit, multi)
121
- if num = AgeConvertors[unit]
121
+ num = AgeConvertors[unit]
122
+ if num
122
123
  return num * multi
123
124
  else
124
125
  self.fail _("Invalid age unit '%{unit}'") % { unit: unit }
@@ -157,7 +158,8 @@ Puppet::Type.newtype(:tidy) do
157
158
  be used."
158
159
 
159
160
  def convert(unit, multi)
160
- if num = { :b => 0, :k => 1, :m => 2, :g => 3, :t => 4 }[unit]
161
+ num = { :b => 0, :k => 1, :m => 2, :g => 3, :t => 4 }[unit]
162
+ if num
161
163
  result = multi
162
164
  num.times do result *= 1024 end
163
165
  return result
@@ -236,7 +238,8 @@ Puppet::Type.newtype(:tidy) do
236
238
 
237
239
  def retrieve
238
240
  # Our ensure property knows how to retrieve everything for us.
239
- if obj = @parameters[:ensure]
241
+ obj = @parameters[:ensure]
242
+ if obj
240
243
  return obj.retrieve
241
244
  else
242
245
  return {}
@@ -282,7 +285,8 @@ Puppet::Type.newtype(:tidy) do
282
285
 
283
286
  files_by_name.keys.sort { |a,b| b <=> a }.each do |path|
284
287
  dir = ::File.dirname(path)
285
- next unless resource = files_by_name[dir]
288
+ resource = files_by_name[dir]
289
+ next unless resource
286
290
  if resource[:require]
287
291
  resource[:require] << Puppet::Resource.new(:file, path)
288
292
  else
@@ -314,17 +318,20 @@ Puppet::Type.newtype(:tidy) do
314
318
  # those files anyway
315
319
  return false if catalog.resource(:file, path)
316
320
 
317
- return false unless stat = self.stat(path)
321
+ stat = self.stat(path)
322
+ return false unless stat
318
323
 
319
324
  return false if stat.ftype == "directory" and ! rmdirs?
320
325
 
321
326
  # The 'matches' parameter isn't OR'ed with the other tests --
322
327
  # it's just used to reduce the list of files we can match.
323
- return false if param = parameter(:matches) and ! param.tidy?(path, stat)
328
+ param = parameter(:matches)
329
+ return false if param && ! param.tidy?(path, stat)
324
330
 
325
331
  tested = false
326
332
  [:age, :size].each do |name|
327
- next unless param = parameter(name)
333
+ param = parameter(name)
334
+ next unless param
328
335
  tested = true
329
336
  return true if param.tidy?(path, stat)
330
337
  end
@@ -147,7 +147,7 @@ module Puppet
147
147
  # We know the 'is' is a number, so we need to convert the 'should' to a number,
148
148
  # too.
149
149
  @should.each do |value|
150
- return true if number = Puppet::Util.gid(value) and is == number
150
+ return true if is == Puppet::Util.gid(value)
151
151
  end
152
152
 
153
153
  false
@@ -156,7 +156,8 @@ module Puppet
156
156
  def sync
157
157
  found = false
158
158
  @should.each do |value|
159
- if number = Puppet::Util.gid(value)
159
+ number = Puppet::Util.gid(value)
160
+ if number
160
161
  provider.gid = number
161
162
  found = true
162
163
  break
@@ -444,7 +445,10 @@ module Puppet
444
445
  autorequire(:group) do
445
446
  autos = []
446
447
 
447
- if obj = @parameters[:gid] and groups = obj.shouldorig
448
+ # autorequire primary group, if managed
449
+ obj = @parameters[:gid]
450
+ groups = obj.shouldorig if obj
451
+ if groups
448
452
  groups = groups.collect { |group|
449
453
  if group =~ /^\d+$/
450
454
  Integer(group)
@@ -455,7 +459,8 @@ module Puppet
455
459
  groups.each { |group|
456
460
  case group
457
461
  when Integer
458
- if resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) and r.should(:gid) == group }
462
+ resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) && r.should(:gid) == group }
463
+ if resource
459
464
  autos << resource
460
465
  end
461
466
  else
@@ -464,8 +469,13 @@ module Puppet
464
469
  }
465
470
  end
466
471
 
467
- if obj = @parameters[:groups] and groups = obj.should
468
- autos += groups.split(",")
472
+ # autorequire groups, excluding primary group, if managed
473
+ obj = @parameters[:groups]
474
+ if obj
475
+ groups = obj.should
476
+ if groups
477
+ autos += groups.split(",")
478
+ end
469
479
  end
470
480
 
471
481
  autos
@@ -522,7 +532,9 @@ module Puppet
522
532
  autorequire(:user) do
523
533
  reqs = []
524
534
 
525
- if roles_property = @parameters[:roles] and roles = roles_property.should
535
+ roles_property = @parameters[:roles]
536
+ roles = roles_property.should if roles_property
537
+ if roles
526
538
  reqs += roles.split(',')
527
539
  end
528
540
 
data/lib/puppet/util.rb CHANGED
@@ -148,7 +148,8 @@ module Util
148
148
 
149
149
  # Change the process to a different user
150
150
  def self.chuser
151
- if group = Puppet[:group]
151
+ group = Puppet[:group]
152
+ if group
152
153
  begin
153
154
  Puppet::Util::SUIDManager.change_group(group, true)
154
155
  rescue => detail
@@ -161,7 +162,8 @@ module Util
161
162
  end
162
163
  end
163
164
 
164
- if user = Puppet[:user]
165
+ user = Puppet[:user]
166
+ if user
165
167
  begin
166
168
  Puppet::Util::SUIDManager.change_user(user, true)
167
169
  rescue => detail
@@ -324,7 +326,8 @@ module Util
324
326
  if Puppet::Util::Platform.windows?
325
327
  path = path.gsub(/\\/, '/')
326
328
 
327
- if unc = /^\/\/([^\/]+)(\/.+)/.match(path)
329
+ unc = /^\/\/([^\/]+)(\/.+)/.match(path)
330
+ if unc
328
331
  params[:host] = unc[1]
329
332
  path = unc[2]
330
333
  elsif path =~ /^[a-z]:\//i
@@ -344,7 +344,7 @@ module Puppet::Util::Checksums
344
344
  def checksum_file(digest, filename, lite = false)
345
345
  buffer = lite ? 512 : 4096
346
346
  File.open(filename, 'rb') do |file|
347
- while content = file.read(buffer)
347
+ while content = file.read(buffer) #rubocop:disable Lint/AssignmentInCondition
348
348
  digest << content
349
349
  break if lite
350
350
  end
@@ -70,7 +70,8 @@ module Puppet::Util::ClassGen
70
70
  retval = true
71
71
  end
72
72
 
73
- if hash = options[:hash] and hash.include? name
73
+ hash = options[:hash]
74
+ if hash && hash.include?(name)
74
75
  hash.delete(name)
75
76
  retval = true
76
77
  end
@@ -84,7 +85,8 @@ module Puppet::Util::ClassGen
84
85
  # Generates the constant to create or remove.
85
86
  # @api private
86
87
  def genconst_string(name, options)
87
- unless const = options[:constant]
88
+ const = options[:constant]
89
+ unless const
88
90
  prefix = options[:prefix] || ""
89
91
  const = prefix + name2const(name)
90
92
  end
@@ -169,7 +171,8 @@ module Puppet::Util::ClassGen
169
171
  def initclass(klass, options)
170
172
  klass.initvars if klass.respond_to? :initvars
171
173
 
172
- if attrs = options[:attributes]
174
+ attrs = options[:attributes]
175
+ if attrs
173
176
  attrs.each do |param, value|
174
177
  method = param.to_s + "="
175
178
  klass.send(method, value) if klass.respond_to? method
@@ -177,7 +180,8 @@ module Puppet::Util::ClassGen
177
180
  end
178
181
 
179
182
  [:include, :extend].each do |method|
180
- if set = options[method]
183
+ set = options[method]
184
+ if set
181
185
  set = [set] unless set.is_a?(Array)
182
186
  set.each do |mod|
183
187
  klass.send(method, mod)
@@ -197,7 +201,8 @@ module Puppet::Util::ClassGen
197
201
  # Store the class in the appropriate places.
198
202
  # @api private
199
203
  def storeclass(klass, klassname, options)
200
- if hash = options[:hash]
204
+ hash = options[:hash]
205
+ if hash
201
206
  if hash.include? klassname and ! options[:overwrite]
202
207
  raise Puppet::SubclassAlreadyDefined,
203
208
  _("Already a generated class named %{klassname}") % { klassname: klassname }
@@ -207,7 +212,8 @@ module Puppet::Util::ClassGen
207
212
  end
208
213
 
209
214
  # If we were told to stick it in a hash, then do so
210
- if array = options[:array]
215
+ array = options[:array]
216
+ if array
211
217
  if (klass.respond_to? :name and
212
218
  array.find { |c| c.name == klassname } and
213
219
  ! options[:overwrite])
@@ -93,10 +93,13 @@ module Puppet
93
93
  end
94
94
  elsif Puppet::Application.available_application_names.include?(subcommand_name)
95
95
  ApplicationSubcommand.new(subcommand_name, self)
96
- elsif path_to_subcommand = external_subcommand
97
- ExternalSubcommand.new(path_to_subcommand, self)
98
96
  else
99
- UnknownSubcommand.new(subcommand_name, self)
97
+ path_to_subcommand = external_subcommand
98
+ if path_to_subcommand
99
+ ExternalSubcommand.new(path_to_subcommand, self)
100
+ else
101
+ UnknownSubcommand.new(subcommand_name, self)
102
+ end
100
103
  end
101
104
  end
102
105
 
@@ -121,7 +124,8 @@ module Puppet
121
124
  # If we cannot find the configured environment, which may not exist,
122
125
  # we do not attempt to add plugin directories to the load path.
123
126
  unless @subcommand_name == 'master' || @subcommand_name == 'agent' || (@subcommand_name == 'device' && (['--apply', '--facts', '--resource'] - @command_line.args).empty?)
124
- if configured_environment = Puppet.lookup(:environments).get(Puppet[:environment])
127
+ configured_environment = Puppet.lookup(:environments).get(Puppet[:environment])
128
+ if configured_environment
125
129
  configured_environment.each_plugin_directory do |dir|
126
130
  $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
127
131
  end