bolt 0.15.0 → 0.16.0

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

Potentially problematic release.


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

Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +30 -131
  3. data/lib/bolt/config.rb +35 -9
  4. data/lib/bolt/executor.rb +33 -7
  5. data/lib/bolt/node.rb +19 -2
  6. data/lib/bolt/node/orch.rb +4 -4
  7. data/lib/bolt/node/ssh.rb +46 -21
  8. data/lib/bolt/node/winrm.rb +12 -23
  9. data/lib/bolt/outputter.rb +9 -0
  10. data/lib/bolt/outputter/human.rb +33 -4
  11. data/lib/bolt/outputter/json.rb +6 -1
  12. data/lib/bolt/pal.rb +87 -20
  13. data/lib/bolt/version.rb +1 -1
  14. data/modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
  15. data/modules/boltlib/lib/puppet/functions/run_plan.rb +18 -1
  16. data/modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
  17. data/modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
  18. data/vendored/facter/lib/facter/virtual.rb +2 -0
  19. data/vendored/hiera/lib/hiera/config.rb +2 -2
  20. data/vendored/hiera/lib/hiera/version.rb +1 -1
  21. data/vendored/puppet/lib/hiera/puppet_function.rb +5 -2
  22. data/vendored/puppet/lib/hiera_puppet.rb +3 -3
  23. data/vendored/puppet/lib/puppet/agent/locker.rb +6 -5
  24. data/vendored/puppet/lib/puppet/application/filebucket.rb +23 -6
  25. data/vendored/puppet/lib/puppet/daemon.rb +2 -2
  26. data/vendored/puppet/lib/puppet/defaults.rb +42 -10
  27. data/vendored/puppet/lib/puppet/error.rb +5 -15
  28. data/vendored/puppet/lib/puppet/external/pson/common.rb +2 -2
  29. data/vendored/puppet/lib/puppet/face/module/build.rb +1 -0
  30. data/vendored/puppet/lib/puppet/face/module/install.rb +1 -0
  31. data/vendored/puppet/lib/puppet/face/module/search.rb +2 -1
  32. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +1 -0
  33. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +1 -0
  34. data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +1 -1
  35. data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -1
  36. data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +21 -9
  37. data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +1 -1
  38. data/vendored/puppet/lib/puppet/forge.rb +2 -1
  39. data/vendored/puppet/lib/puppet/functions/binary_file.rb +1 -0
  40. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  41. data/vendored/puppet/lib/puppet/functions/module_directory.rb +41 -0
  42. data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -1
  43. data/vendored/puppet/lib/puppet/functions/unique.rb +1 -1
  44. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +1 -1
  45. data/vendored/puppet/lib/puppet/gettext/config.rb +10 -5
  46. data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +1 -1
  47. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +1 -1
  48. data/vendored/puppet/lib/puppet/indirector/exec.rb +1 -1
  49. data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +3 -3
  50. data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +2 -2
  51. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +10 -3
  52. data/vendored/puppet/lib/puppet/indirector/indirection.rb +17 -9
  53. data/vendored/puppet/lib/puppet/indirector/ldap.rb +2 -2
  54. data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
  55. data/vendored/puppet/lib/puppet/indirector/rest.rb +2 -1
  56. data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +2 -2
  57. data/vendored/puppet/lib/puppet/indirector/terminus.rb +3 -3
  58. data/vendored/puppet/lib/puppet/interface.rb +1 -1
  59. data/vendored/puppet/lib/puppet/interface/action.rb +41 -24
  60. data/vendored/puppet/lib/puppet/interface/action_builder.rb +14 -5
  61. data/vendored/puppet/lib/puppet/interface/action_manager.rb +1 -1
  62. data/vendored/puppet/lib/puppet/interface/documentation.rb +21 -10
  63. data/vendored/puppet/lib/puppet/interface/face_collection.rb +4 -2
  64. data/vendored/puppet/lib/puppet/interface/option.rb +36 -15
  65. data/vendored/puppet/lib/puppet/interface/option_builder.rb +23 -9
  66. data/vendored/puppet/lib/puppet/interface/option_manager.rb +8 -3
  67. data/vendored/puppet/lib/puppet/metatype/manager.rb +7 -3
  68. data/vendored/puppet/lib/puppet/module.rb +2 -1
  69. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +4 -0
  70. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +3 -0
  71. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
  72. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +3 -0
  73. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +3 -3
  74. data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +10 -5
  75. data/vendored/puppet/lib/puppet/network/authstore.rb +2 -2
  76. data/vendored/puppet/lib/puppet/network/client_request.rb +1 -1
  77. data/vendored/puppet/lib/puppet/network/format.rb +3 -3
  78. data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +1 -1
  79. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
  80. data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -3
  81. data/vendored/puppet/lib/puppet/node.rb +16 -7
  82. data/vendored/puppet/lib/puppet/parameter.rb +3 -3
  83. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +5 -2
  84. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +1 -1
  85. data/vendored/puppet/lib/puppet/parser/ast/node.rb +2 -2
  86. data/vendored/puppet/lib/puppet/parser/compiler.rb +6 -5
  87. data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
  88. data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
  89. data/vendored/puppet/lib/puppet/parser/functions/generate.rb +2 -4
  90. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -2
  91. data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +5 -0
  92. data/vendored/puppet/lib/puppet/parser/functions/template.rb +6 -2
  93. data/vendored/puppet/lib/puppet/parser/resource.rb +18 -91
  94. data/vendored/puppet/lib/puppet/parser/scope.rb +12 -11
  95. data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +1 -1
  96. data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
  97. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  98. data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
  99. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
  100. data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  101. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
  102. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
  103. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -6
  104. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
  105. data/vendored/puppet/lib/puppet/pops/functions/function.rb +8 -2
  106. data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +7 -2
  107. data/vendored/puppet/lib/puppet/pops/issues.rb +14 -4
  108. data/vendored/puppet/lib/puppet/pops/label_provider.rb +1 -1
  109. data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +2 -2
  110. data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  111. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +6 -1
  112. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
  113. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +27 -6
  114. data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +2 -2
  115. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +1 -1
  116. data/vendored/puppet/lib/puppet/pops/loaders.rb +7 -3
  117. data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +2 -1
  118. data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +6 -3
  119. data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +8 -8
  120. data/vendored/puppet/lib/puppet/pops/model/factory.rb +4 -2
  121. data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  122. data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
  123. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +6 -2
  124. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +36 -15
  125. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -1
  126. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +3 -1
  127. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +4 -1
  128. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +75 -7
  129. data/vendored/puppet/lib/puppet/pops/types/types.rb +9 -5
  130. data/vendored/puppet/lib/puppet/pops/validation.rb +14 -12
  131. data/vendored/puppet/lib/puppet/property.rb +14 -6
  132. data/vendored/puppet/lib/puppet/property/ensure.rb +2 -2
  133. data/vendored/puppet/lib/puppet/provider.rb +4 -4
  134. data/vendored/puppet/lib/puppet/provider/group/aix.rb +4 -2
  135. data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +25 -1
  136. data/vendored/puppet/lib/puppet/provider/ldap.rb +2 -2
  137. data/vendored/puppet/lib/puppet/provider/naginator.rb +1 -1
  138. data/vendored/puppet/lib/puppet/provider/nameservice.rb +7 -4
  139. data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
  140. data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +13 -24
  141. data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +14 -14
  142. data/vendored/puppet/lib/puppet/provider/package/aix.rb +1 -1
  143. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -2
  144. data/vendored/puppet/lib/puppet/provider/package/yum.rb +1 -1
  145. data/vendored/puppet/lib/puppet/provider/parsedfile.rb +4 -4
  146. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  147. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -2
  148. data/vendored/puppet/lib/puppet/provider/service/runit.rb +2 -1
  149. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -0
  150. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +1 -1
  151. data/vendored/puppet/lib/puppet/provider/user/aix.rb +13 -6
  152. data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +2 -1
  153. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +33 -4
  154. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -1
  155. data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +2 -2
  156. data/vendored/puppet/lib/puppet/relationship.rb +2 -1
  157. data/vendored/puppet/lib/puppet/reports/store.rb +1 -1
  158. data/vendored/puppet/lib/puppet/resource.rb +7 -5
  159. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +14 -11
  160. data/vendored/puppet/lib/puppet/resource/catalog.rb +33 -18
  161. data/vendored/puppet/lib/puppet/resource/type.rb +5 -5
  162. data/vendored/puppet/lib/puppet/settings.rb +19 -13
  163. data/vendored/puppet/lib/puppet/settings/base_setting.rb +23 -8
  164. data/vendored/puppet/lib/puppet/settings/config_file.rb +14 -4
  165. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +5 -7
  166. data/vendored/puppet/lib/puppet/settings/ini_file.rb +4 -0
  167. data/vendored/puppet/lib/puppet/ssl/base.rb +9 -4
  168. data/vendored/puppet/lib/puppet/ssl/oids.rb +8 -2
  169. data/vendored/puppet/lib/puppet/transaction.rb +6 -2
  170. data/vendored/puppet/lib/puppet/transaction/persistence.rb +15 -0
  171. data/vendored/puppet/lib/puppet/transaction/report.rb +9 -1
  172. data/vendored/puppet/lib/puppet/type.rb +26 -26
  173. data/vendored/puppet/lib/puppet/type/file.rb +2 -1
  174. data/vendored/puppet/lib/puppet/type/file/data_sync.rb +2 -1
  175. data/vendored/puppet/lib/puppet/type/file/source.rb +1 -1
  176. data/vendored/puppet/lib/puppet/type/group.rb +4 -1
  177. data/vendored/puppet/lib/puppet/type/mount.rb +1 -1
  178. data/vendored/puppet/lib/puppet/type/resources.rb +1 -1
  179. data/vendored/puppet/lib/puppet/type/user.rb +12 -7
  180. data/vendored/puppet/lib/puppet/type/zone.rb +1 -1
  181. data/vendored/puppet/lib/puppet/util.rb +15 -21
  182. data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +6 -4
  183. data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +6 -5
  184. data/vendored/puppet/lib/puppet/util/errors.rb +59 -8
  185. data/vendored/puppet/lib/puppet/util/fileparsing.rb +3 -5
  186. data/vendored/puppet/lib/puppet/util/http_proxy.rb +14 -6
  187. data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -3
  188. data/vendored/puppet/lib/puppet/util/ldap/manager.rb +6 -3
  189. data/vendored/puppet/lib/puppet/util/log.rb +15 -21
  190. data/vendored/puppet/lib/puppet/util/logging.rb +21 -28
  191. data/vendored/puppet/lib/puppet/util/methodhelper.rb +1 -1
  192. data/vendored/puppet/lib/puppet/util/nagios_maker.rb +1 -1
  193. data/vendored/puppet/lib/puppet/util/network_device/config.rb +20 -13
  194. data/vendored/puppet/lib/puppet/util/platform.rb +13 -0
  195. data/vendored/puppet/lib/puppet/util/posix.rb +1 -1
  196. data/vendored/puppet/lib/puppet/util/provider_features.rb +1 -1
  197. data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  198. data/vendored/puppet/lib/puppet/util/selinux.rb +1 -1
  199. data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +10 -5
  200. data/vendored/puppet/lib/puppet/util/windows/file.rb +61 -9
  201. data/vendored/puppet/lib/puppet/util/windows/process.rb +1 -1
  202. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +2 -2
  203. data/vendored/puppet/lib/puppet/version.rb +1 -1
  204. data/vendored/puppet/lib/puppet_pal.rb +23 -22
  205. metadata +4 -2
@@ -63,7 +63,8 @@ class Puppet::Util::Log
63
63
  destinations.keys.each { |dest|
64
64
  close(dest)
65
65
  }
66
- raise Puppet::DevError.new("Log.close_all failed to close #{@destinations.keys.inspect}") if !@destinations.empty?
66
+ #TRANSLATORS "Log.close_all" is a method name and should not be translated
67
+ raise Puppet::DevError.new(_("Log.close_all failed to close %{destinations}") % { destinations: @destinations.keys.inspect }) if !@destinations.empty?
67
68
  end
68
69
 
69
70
  # Flush any log destinations that support such operations.
@@ -82,8 +83,8 @@ class Puppet::Util::Log
82
83
  # Create a new log message. The primary role of this method is to
83
84
  # avoid creating log messages below the loglevel.
84
85
  def Log.create(hash)
85
- raise Puppet::DevError, "Logs require a level" unless hash.include?(:level)
86
- raise Puppet::DevError, "Invalid log level #{hash[:level]}" unless @levels.index(hash[:level])
86
+ raise Puppet::DevError, _("Logs require a level") unless hash.include?(:level)
87
+ raise Puppet::DevError, _("Invalid log level %{level}") % { level: hash[:level] } unless @levels.index(hash[:level])
87
88
  @levels.index(hash[:level]) >= @loglevel ? Puppet::Util::Log.new(hash) : nil
88
89
  end
89
90
 
@@ -105,7 +106,7 @@ class Puppet::Util::Log
105
106
  def Log.level=(level)
106
107
  level = level.intern unless level.is_a?(Symbol)
107
108
 
108
- raise Puppet::DevError, "Invalid loglevel #{level}" unless @levels.include?(level)
109
+ raise Puppet::DevError, _("Invalid loglevel %{level}") % { level: level } unless @levels.include?(level)
109
110
 
110
111
  @loglevel = @levels.index(level)
111
112
 
@@ -132,7 +133,7 @@ class Puppet::Util::Log
132
133
  return
133
134
  end
134
135
 
135
- raise Puppet::DevError, "Unknown destination type #{dest}" unless type
136
+ raise Puppet::DevError, _("Unknown destination type %{dest}") % { dest: dest} unless type
136
137
 
137
138
  begin
138
139
  if type.instance_method(:initialize).arity == 1
@@ -358,15 +359,18 @@ class Puppet::Util::Log
358
359
  end
359
360
 
360
361
  def message=(msg)
361
- raise ArgumentError, "Puppet::Util::Log requires a message" unless msg
362
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
363
+ raise ArgumentError, _("Puppet::Util::Log requires a message") unless msg
362
364
  @message = msg.to_s
363
365
  end
364
366
 
365
367
  def level=(level)
366
- raise ArgumentError, "Puppet::Util::Log requires a log level" unless level
367
- raise ArgumentError, "Puppet::Util::Log requires a symbol or string" unless level.respond_to? "to_sym"
368
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
369
+ raise ArgumentError, _("Puppet::Util::Log requires a log level") unless level
370
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
371
+ raise ArgumentError, _("Puppet::Util::Log requires a symbol or string") unless level.respond_to? "to_sym"
368
372
  @level = level.to_sym
369
- raise ArgumentError, "Invalid log level #{@level}" unless self.class.validlevel?(@level)
373
+ raise ArgumentError, _("Invalid log level %{level}") % { level: @level } unless self.class.validlevel?(@level)
370
374
 
371
375
  # Tag myself with my log level
372
376
  tag(level)
@@ -395,18 +399,8 @@ class Puppet::Util::Log
395
399
  # Issue based messages do not have details in the message. It
396
400
  # must be appended here
397
401
  unless issue_code.nil?
398
- msg = _("Could not parse for environment %{env}: %{msg}") % { env: environment, msg: msg } unless environment.nil?
399
- if file && line && pos
400
- msg = _("%{msg} at %{file}:%{line}:%{pos}") % { msg: msg, file: file, line: line, pos: pos }
401
- elsif file and line
402
- msg = _("%{msg} at %{file}:%{line}") % { msg: msg, file: file, line: line }
403
- elsif line && pos
404
- msg = _("%{msg} at line %{line}:%{pos}") % { msg: msg, line: line, pos: pos }
405
- elsif line
406
- msg = _("%{msg} at line %{line}") % { msg: msg, line: line }
407
- elsif file
408
- msg = _("%{msg} in %{file}") % { msg: msg, file: file }
409
- end
402
+ msg = _("Could not parse for environment %{environment}: %{msg}") % { environment: environment, msg: msg } unless environment.nil?
403
+ msg += Puppet::Util::Errors.error_location_with_space(file, line, pos)
410
404
  msg = _("%{msg} on node %{node}") % { msg: msg, node: node } unless node.nil?
411
405
  if @backtrace.is_a?(Array)
412
406
  msg += "\n"
@@ -1,7 +1,6 @@
1
1
  # A module to make logging a bit easier.
2
2
  require 'puppet/util/log'
3
3
  require 'puppet/error'
4
- require 'puppet/util/multi_match.rb'
5
4
 
6
5
  require 'facter'
7
6
 
@@ -146,16 +145,12 @@ module Logging
146
145
  key = options[:key]
147
146
  file = options[:file]
148
147
  line = options[:line]
149
- raise(Puppet::DevError, "Need either :file and :line, or :key") if (key.nil?) && (file.nil? || line.nil?)
148
+ #TRANSLATORS the literals ":file", ":line", and ":key" should not be translated
149
+ raise Puppet::DevError, _("Need either :file and :line, or :key") if (key.nil?) && (file.nil? || line.nil?)
150
150
 
151
151
  key ||= "#{file}:#{line}"
152
152
  issue_deprecation_warning(message, key, file, line, false)
153
153
  end
154
- MM = MultiMatch
155
- FILE_AND_LINE = MM::TUPLE
156
- FILE_NO_LINE = MM.new(MM::NOT_NIL, nil).freeze
157
- NO_FILE_LINE = MM.new(nil, MM::NOT_NIL).freeze
158
- SUPPRESS_FILE_LINE = MM.new(:default, :default).freeze
159
154
 
160
155
  # Logs a (non deprecation) warning once for a given key.
161
156
  #
@@ -175,19 +170,17 @@ module Logging
175
170
  if $unique_warnings.length < 100 then
176
171
  if (! $unique_warnings.has_key?(key)) then
177
172
  $unique_warnings[key] = message
178
- call_trace =
179
- case MM.new(file, line)
180
- when SUPPRESS_FILE_LINE
181
- ''
182
- when FILE_AND_LINE
183
- _("\n (at %{file}:%{line})") % { file: file, line: line }
184
- when FILE_NO_LINE
185
- _("\n (in %{file})") % { file: file }
186
- when NO_FILE_LINE
187
- _("\n (in unknown file, line %{line})") % { line: line }
188
- else
189
- _("\n (file & line not available)")
190
- end
173
+ call_trace = if file == :default and line == :default
174
+ # Suppress the file and line number output
175
+ ''
176
+ else
177
+ error_location_str = Puppet::Util::Errors.error_location(file, line)
178
+ if error_location_str.empty?
179
+ '\n ' + _('(file & line not available)')
180
+ else
181
+ "\n %{error_location}" % { error_location: error_location_str }
182
+ end
183
+ end
191
184
  send_log(level, "#{message}#{call_trace}")
192
185
  end
193
186
  end
@@ -279,17 +272,17 @@ module Logging
279
272
  def issue_deprecation_warning(message, key, file, line, use_caller)
280
273
  return if Puppet[:disable_warnings].include?('deprecations')
281
274
  $deprecation_warnings ||= {}
282
- if $deprecation_warnings.length < 100 then
275
+ if $deprecation_warnings.length < 100
283
276
  key ||= (offender = get_deprecation_offender)
284
- if (! $deprecation_warnings.has_key?(key)) then
277
+ unless $deprecation_warnings.has_key?(key)
285
278
  $deprecation_warnings[key] = message
286
279
  # split out to allow translation
287
- unknown = _('unknown')
288
- call_trace = use_caller ?
289
- (offender || get_deprecation_offender).join('; ') :
290
- "#{file || unknown}:#{line || unknown}"
291
- #TRANSLATORS error message with origin location
292
- warning(_("%{message}\n (at %{call_trace})") % { message: message, call_trace: call_trace })
280
+ call_trace = if use_caller
281
+ _("(location: %{location})") % { location: (offender || get_deprecation_offender).join('; ') }
282
+ else
283
+ Puppet::Util::Errors.error_location_with_unknowns(file, line)
284
+ end
285
+ warning("%{message}\n %{call_trace}" % { message: message, call_trace: call_trace })
293
286
  end
294
287
  end
295
288
  end
@@ -13,7 +13,7 @@ module Puppet::Util::MethodHelper
13
13
  if respond_to? method
14
14
  self.send(method, value)
15
15
  else
16
- raise ArgumentError, "Invalid parameter #{param} to object class #{self.class}"
16
+ raise ArgumentError, _("Invalid parameter %{parameter} to object class %{class_name}") % { parameter: param, class_name: self.class }
17
17
  end
18
18
  end
19
19
  end
@@ -9,7 +9,7 @@ module Puppet::Util::NagiosMaker
9
9
  name = name.to_sym
10
10
  full_name = ("nagios_#{name}").to_sym
11
11
 
12
- raise(Puppet::DevError, "No nagios type for #{name}") unless nagtype = Nagios::Base.type(name)
12
+ raise Puppet::DevError, _("No nagios type for %{name}") % { name: name } unless nagtype = Nagios::Base.type(name)
13
13
 
14
14
  type = Puppet::Type.newtype(full_name) do
15
15
 
@@ -39,34 +39,40 @@ class Puppet::Util::NetworkDevice::Config
39
39
  begin
40
40
  devices = {}
41
41
  device = nil
42
- File.open(@file) { |f|
43
- count = 1
44
- f.each { |line|
42
+ File.open(@file) do |f|
43
+ file_line_count = 1
44
+ f.each do |line|
45
45
  case line
46
46
  when /^\s*#/ # skip comments
47
- count += 1
47
+ file_line_count += 1
48
48
  next
49
49
  when /^\s*$/ # skip blank lines
50
- count += 1
50
+ file_line_count += 1
51
51
  next
52
52
  when /^\[([\w.-]+)\]\s*$/ # [device.fqdn]
53
53
  name = $1
54
54
  name.chomp!
55
- raise Puppet::Error, _("Duplicate device found at line %{count}, already found at %{line}") % { count: count, line: device.line } if devices.include?(name)
55
+ if devices.include?(name)
56
+ file_error_location = Puppet::Util::Errors.error_location(nil, file_line_count)
57
+ device_error_location = Puppet::Util::Errors.error_location(nil, device.line)
58
+ raise Puppet::Error, _("Duplicate device found at %{file_error_location}, already found at %{device_error_location}") %
59
+ { file_error_location: file_error_location, device_error_location: device_error_location }
60
+ end
56
61
  device = OpenStruct.new
57
62
  device.name = name
58
- device.line = count
63
+ device.line = file_line_count
59
64
  device.options = { :debug => false }
60
65
  Puppet.debug "found device: #{device.name} at #{device.line}"
61
66
  devices[name] = device
62
67
  when /^\s*(type|url|debug)(\s+(.+)\s*)*$/
63
- parse_directive(device, $1, $3, count)
68
+ parse_directive(device, $1, $3, file_line_count)
64
69
  else
65
- raise Puppet::Error, _("Invalid line %{count}: %{line}") % { count: count, line: line }
70
+ error_location_str = Puppet::Util::Errors.error_location(nil, file_line_count)
71
+ raise Puppet::Error, _("Invalid entry at %{error_location}: %{file_text}") %
72
+ { error_location: error_location_str, file_text: line }
66
73
  end
67
- count += 1
68
- }
69
- }
74
+ end
75
+ end
70
76
  rescue Errno::EACCES
71
77
  Puppet.err _("Configuration error: Cannot read %{file}; cannot serve") % { file: @file }
72
78
  #raise Puppet::Error, "Cannot read #{@config}"
@@ -91,7 +97,8 @@ class Puppet::Util::NetworkDevice::Config
91
97
  when "debug"
92
98
  device.options[:debug] = true
93
99
  else
94
- raise Puppet::Error, _("Invalid argument '%{var}' at line %{count}") % { var: var, count: count }
100
+ error_location_str = Puppet::Util::Errors.error_location(nil, count)
101
+ raise Puppet::Error, _("Invalid argument '%{var}' at %{error_location}") % { var: var, error_location: error_location_str }
95
102
  end
96
103
  end
97
104
 
@@ -1,6 +1,9 @@
1
1
  module Puppet
2
2
  module Util
3
3
  module Platform
4
+
5
+ FIPS_STATUS_FILE = "/proc/sys/crypto/fips_enabled".freeze
6
+
4
7
  def windows?
5
8
  # Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard
6
9
  # library uses that to test what platform it's on. In some places we
@@ -17,6 +20,16 @@ module Puppet
17
20
  %w{/usr/sbin /sbin}
18
21
  end
19
22
  module_function :default_paths
23
+
24
+ @fips_enabled = !windows? &&
25
+ File.exist?(FIPS_STATUS_FILE) &&
26
+ File.read(FIPS_STATUS_FILE, 1) == '1'
27
+
28
+ def fips_enabled?
29
+ @fips_enabled
30
+ end
31
+ module_function :fips_enabled?
32
+
20
33
  end
21
34
  end
22
35
  end
@@ -17,7 +17,7 @@ module Puppet::Util::POSIX
17
17
  # method search_posix_field in the gid and uid methods if a sanity check
18
18
  # fails
19
19
  def get_posix_field(space, field, id)
20
- raise Puppet::DevError, "Did not get id from caller" unless id
20
+ raise Puppet::DevError, _("Did not get id from caller") unless id
21
21
 
22
22
  if id.is_a?(Integer)
23
23
  if id > Puppet[:maximum_uid].to_i
@@ -63,7 +63,7 @@ module Puppet::Util::ProviderFeatures
63
63
  # @todo How methods that determine if the feature is present are specified.
64
64
  def feature(name, docs, hash = {})
65
65
  @features ||= {}
66
- raise(Puppet::DevError, "Feature #{name} is already defined") if @features.include?(name)
66
+ raise Puppet::DevError, _("Feature %{name} is already defined") % { name: name } if @features.include?(name)
67
67
  begin
68
68
  obj = ProviderFeature.new(name, docs, hash)
69
69
  @features[obj.name] = obj
@@ -245,7 +245,7 @@ module Generators
245
245
  end
246
246
  end
247
247
 
248
- def gen_composite_index(collection, template, filename)\
248
+ def gen_composite_index(collection, template, filename)
249
249
  return if Puppet::FileSystem.exist?(filename)
250
250
 
251
251
  template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
@@ -240,7 +240,7 @@ module Puppet::Util::SELinux
240
240
  # while we try and figure out what file-system the target lives on.
241
241
  path = Pathname(path).cleanpath
242
242
  unless path.absolute?
243
- raise Puppet::DevError, "got a relative path in SELinux find_fs: #{path}"
243
+ raise Puppet::DevError, _("got a relative path in SELinux find_fs: %{path}") % { path: path }
244
244
  end
245
245
 
246
246
  # Now, walk up the tree until we find a match for that path in the hash.
@@ -31,7 +31,8 @@ class Puppet::Util::Windows::EventLog
31
31
  def initialize(source_name = 'Puppet')
32
32
  @eventlog_handle = RegisterEventSourceW(FFI::Pointer::NULL, wide_string(source_name))
33
33
  if @eventlog_handle == NULL_HANDLE
34
- raise EventLogError.new("RegisterEventSourceW failed to open Windows eventlog", FFI.errno)
34
+ #TRANSLATORS 'Windows' is the operating system and 'RegisterEventSourceW' is a API call and should not be translated
35
+ raise EventLogError.new(_("RegisterEventSourceW failed to open Windows eventlog"), FFI.errno)
35
36
  end
36
37
  end
37
38
 
@@ -55,7 +56,9 @@ class Puppet::Util::Windows::EventLog
55
56
  # @return [void]
56
57
  # @api public
57
58
  def report_event(args = {})
58
- raise ArgumentError, "data must be a string, not #{args[:data].class}" unless args[:data].is_a?(String)
59
+ unless args[:data].is_a?(String)
60
+ raise ArgumentError, _("data must be a string, not %{class_name}") % { class_name: args[:data].class }
61
+ end
59
62
  from_string_to_wide_string(args[:data]) do |message_ptr|
60
63
  FFI::MemoryPointer.new(:pointer) do |message_array_ptr|
61
64
  message_array_ptr.write_pointer(message_ptr)
@@ -69,7 +72,8 @@ class Puppet::Util::Windows::EventLog
69
72
  num_strings, raw_data_size, message_array_ptr, raw_data)
70
73
 
71
74
  if report_result == WIN32_FALSE
72
- raise EventLogError.new("ReportEventW failed to report event to Windows eventlog", FFI.errno)
75
+ #TRANSLATORS 'Windows' is the operating system and 'ReportEventW' is a API call and should not be translated
76
+ raise EventLogError.new(_("ReportEventW failed to report event to Windows eventlog"), FFI.errno)
73
77
  end
74
78
  end
75
79
  end
@@ -92,7 +96,7 @@ class Puppet::Util::Windows::EventLog
92
96
  when :err,:alert,:emerg,:crit
93
97
  [EVENTLOG_ERROR_TYPE, 0x03]
94
98
  else
95
- raise ArgumentError, "Invalid log level #{level}"
99
+ raise ArgumentError, _("Invalid log level %{level}") % { level: level }
96
100
  end
97
101
  end
98
102
  end
@@ -110,7 +114,8 @@ class Puppet::Util::Windows::EventLog
110
114
  else
111
115
  class EventLogError < RuntimeError
112
116
  def initialize(msg, code)
113
- super(msg + " (Win32 error: #{code})")
117
+ #TRANSLATORS 'Win32' is the Windows API and should not be translated
118
+ super(msg + ' ' + _("(Win32 error: %{detail})") % { detail: code})
114
119
  end
115
120
  end
116
121
  end
@@ -111,11 +111,15 @@ module Puppet::Util::Windows::File
111
111
 
112
112
  # return true if path exists and it's not a symlink
113
113
  # Other file attributes are ignored. https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
114
- return true if (result & FILE_ATTRIBUTE_REPARSE_POINT) != FILE_ATTRIBUTE_REPARSE_POINT
115
-
116
- # walk the symlink and try again...
117
- seen_paths << path.downcase
118
- path = readlink(path)
114
+ reparse_point = (result & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
115
+ if reparse_point && symlink_reparse_point?(path)
116
+ # walk the symlink and try again...
117
+ seen_paths << path.downcase
118
+ path = readlink(path)
119
+ else
120
+ # file was found and its not a symlink
121
+ return true
122
+ end
119
123
  end
120
124
 
121
125
  false
@@ -177,6 +181,18 @@ module Puppet::Util::Windows::File
177
181
  "#{flags_and_attributes.to_s(8)}, #{template_file_handle})")
178
182
  end
179
183
 
184
+ IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
185
+ IO_REPARSE_TAG_HSM = 0xC0000004
186
+ IO_REPARSE_TAG_HSM2 = 0x80000006
187
+ IO_REPARSE_TAG_SIS = 0x80000007
188
+ IO_REPARSE_TAG_WIM = 0x80000008
189
+ IO_REPARSE_TAG_CSV = 0x80000009
190
+ IO_REPARSE_TAG_DFS = 0x8000000A
191
+ IO_REPARSE_TAG_SYMLINK = 0xA000000C
192
+ IO_REPARSE_TAG_DFSR = 0x80000012
193
+ IO_REPARSE_TAG_DEDUP = 0x80000013
194
+ IO_REPARSE_TAG_NFS = 0x80000014
195
+
180
196
  def self.get_reparse_point_data(handle, &block)
181
197
  # must be multiple of 1024, min 10240
182
198
  FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) do |reparse_data_buffer_ptr|
@@ -184,11 +200,11 @@ module Puppet::Util::Windows::File
184
200
 
185
201
  reparse_tag = reparse_data_buffer_ptr.read_win32_ulong
186
202
  buffer_type = case reparse_tag
187
- when 0xA000000C
203
+ when IO_REPARSE_TAG_SYMLINK
188
204
  SYMLINK_REPARSE_DATA_BUFFER
189
- when 0xA0000003
205
+ when IO_REPARSE_TAG_MOUNT_POINT
190
206
  MOUNT_POINT_REPARSE_DATA_BUFFER
191
- when 0x80000014
207
+ when IO_REPARSE_TAG_NFS
192
208
  raise Puppet::Util::Windows::Error.new("Retrieving NFS reparse point data is unsupported")
193
209
  else
194
210
  raise Puppet::Util::Windows::Error.new("DeviceIoControl(#{handle}, " +
@@ -202,6 +218,20 @@ module Puppet::Util::Windows::File
202
218
  nil
203
219
  end
204
220
 
221
+ def self.get_reparse_point_tag(handle)
222
+ reparse_tag = nil
223
+
224
+ # must be multiple of 1024, min 10240
225
+ FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) do |reparse_data_buffer_ptr|
226
+ device_io_control(handle, FSCTL_GET_REPARSE_POINT, nil, reparse_data_buffer_ptr)
227
+
228
+ # DWORD ReparseTag is the first member of the struct
229
+ reparse_tag = reparse_data_buffer_ptr.read_win32_ulong
230
+ end
231
+
232
+ reparse_tag
233
+ end
234
+
205
235
  def self.device_io_control(handle, io_control_code, in_buffer = nil, out_buffer = nil)
206
236
  if out_buffer.nil?
207
237
  raise Puppet::Util::Windows::Error.new(_("out_buffer is required"))
@@ -229,12 +259,18 @@ module Puppet::Util::Windows::File
229
259
  end
230
260
 
231
261
  FILE_ATTRIBUTE_REPARSE_POINT = 0x400
232
- def symlink?(file_name)
262
+ def reparse_point?(file_name)
233
263
  attributes = get_attributes(file_name, false)
234
264
 
235
265
  return false if (attributes == INVALID_FILE_ATTRIBUTES)
236
266
  (attributes & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
237
267
  end
268
+ module_function :reparse_point?
269
+
270
+ def symlink?(file_name)
271
+ # Puppet currently only handles mount point and symlink reparse points, ignores others
272
+ reparse_point?(file_name) && symlink_reparse_point?(file_name)
273
+ end
238
274
  module_function :symlink?
239
275
 
240
276
  GENERIC_READ = 0x80000000
@@ -375,6 +411,22 @@ module Puppet::Util::Windows::File
375
411
  path
376
412
  end
377
413
 
414
+ # these reparse point types are the only ones Puppet currently understands
415
+ # so rather than raising an exception in readlink, prefer to not consider
416
+ # the path a symlink when stat'ing later
417
+ def self.symlink_reparse_point?(path)
418
+ symlink = false
419
+
420
+ open_symlink(path) do |handle|
421
+ symlink = [
422
+ IO_REPARSE_TAG_SYMLINK,
423
+ IO_REPARSE_TAG_MOUNT_POINT
424
+ ].include?(get_reparse_point_tag(handle))
425
+ end
426
+
427
+ symlink
428
+ end
429
+
378
430
  ffi_convention :stdcall
379
431
 
380
432
  # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365512(v=vs.85).aspx