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
@@ -42,7 +42,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
42
42
  end
43
43
  }
44
44
 
45
- optional_commands :localadd => "luseradd"
45
+ optional_commands :localadd => "luseradd", :localdelete => "luserdel", :localmodify => "lusermod", :localpassword => "lchage"
46
46
  has_feature :libuser if Puppet.features.libuser?
47
47
 
48
48
  def exists?
@@ -157,7 +157,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
157
157
  # sort them to have a predictable command line in tests
158
158
  Puppet::Type.type(:user).validproperties.sort.each do |property|
159
159
  next if property == :ensure
160
- next if property.to_s =~ /password_.+_age/
160
+ next if property_manages_password_age?(property)
161
161
  next if property == :groups and @resource.forcelocal?
162
162
  next if property == :expiry and @resource.forcelocal?
163
163
  # the value needs to be quoted, mostly because -c might
@@ -186,18 +186,43 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
186
186
  cmd << @resource[:name]
187
187
  end
188
188
 
189
+ def modifycmd(param, value)
190
+ if @resource.forcelocal?
191
+ cmd = [command(property_manages_password_age?(param) ? :localpassword : :localmodify)]
192
+ @custom_environment = Puppet::Util::Libuser.getenv
193
+ else
194
+ cmd = [command(property_manages_password_age?(param) ? :password : :modify)]
195
+ end
196
+ cmd << flag(param) << value
197
+ cmd += check_allow_dup
198
+ cmd << @resource[:name]
199
+
200
+ cmd
201
+ end
202
+
189
203
  def deletecmd
190
- cmd = [command(:delete)]
204
+ if @resource.forcelocal?
205
+ cmd = [command(:localdelete)]
206
+ @custom_environment = Puppet::Util::Libuser.getenv
207
+ else
208
+ cmd = [command(:delete)]
209
+ end
191
210
  cmd += @resource.managehome? ? ['-r'] : []
192
211
  cmd << @resource[:name]
193
212
  end
194
213
 
195
214
  def passcmd
215
+ if @resource.forcelocal?
216
+ cmd = command(:localpassword)
217
+ @custom_environment = Puppet::Util::Libuser.getenv
218
+ else
219
+ cmd = command(:password)
220
+ end
196
221
  age_limits = [:password_min_age, :password_max_age, :password_warn_days].select { |property| @resource.should(property) }
197
222
  if age_limits.empty?
198
223
  nil
199
224
  else
200
- [command(:password),age_limits.collect { |property| [flag(property), @resource.should(property)]}, @resource[:name]].flatten
225
+ [cmd, age_limits.collect { |property| [flag(property), @resource.should(property)]}, @resource[:name]].flatten
201
226
  end
202
227
  end
203
228
 
@@ -229,4 +254,8 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
229
254
  def groups?
230
255
  !!@resource[:groups]
231
256
  end
257
+
258
+ def property_manages_password_age?(property)
259
+ property.to_s =~ /password_.+_age|password_warn_days/
260
+ end
232
261
  end
@@ -189,7 +189,8 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
189
189
  inifile.each_file do |file|
190
190
  current_mode = Puppet::FileSystem.stat(file).mode & 0777
191
191
  unless current_mode == target_mode
192
- resource.info "changing mode of #{file} from %03o to %03o" % [current_mode, target_mode]
192
+ resource.info _("changing mode of %{file} from %{current_mode} to %{target_mode}") %
193
+ { file: file, current_mode: "%03o" % current_mode, target_mode: "%03o" % target_mode }
193
194
  Puppet::FileSystem.chmod(target_mode, file)
194
195
  end
195
196
  end
@@ -81,7 +81,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
81
81
  elsif interface
82
82
  "remove net physical=#{interface}"
83
83
  else
84
- raise ArgumentError, "can not remove network based on default router"
84
+ raise ArgumentError, _("can not remove network based on default router")
85
85
  end
86
86
  else self.fail action
87
87
  end
@@ -155,7 +155,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
155
155
  command = "#{command(:cfg)} -z #{@resource[:name]} -f -"
156
156
  r = exec_cmd(:cmd => command, :input => str)
157
157
  if r[:exit] != 0 or r[:out] =~ /not allowed/
158
- raise ArgumentError, "Failed to apply configuration"
158
+ raise ArgumentError, _("Failed to apply configuration")
159
159
  end
160
160
  end
161
161
 
@@ -30,7 +30,8 @@ class Puppet::Relationship
30
30
  end
31
31
 
32
32
  def event=(event)
33
- raise ArgumentError, "You must pass a callback for non-NONE events" if event != :NONE and ! callback
33
+ #TRANSLATORS 'NONE' should not be translated
34
+ raise ArgumentError, _("You must pass a callback for non-NONE events") if event != :NONE and ! callback
34
35
  @event = event
35
36
  end
36
37
 
@@ -61,7 +61,7 @@ Puppet::Reports.register_report(:store) do
61
61
 
62
62
  def validate_host(host)
63
63
  if host =~ Regexp.union(/[#{SEPARATOR}]/, /\A\.\.?\Z/)
64
- raise ArgumentError, "Invalid node name #{host.inspect}"
64
+ raise ArgumentError, _("Invalid node name %{host}") % { host: host.inspect }
65
65
  end
66
66
  end
67
67
  module_function :validate_host
@@ -251,8 +251,10 @@ class Puppet::Resource
251
251
  @sensitive_parameters.replace(type.sensitive_parameters)
252
252
  else
253
253
  if type.is_a?(Hash)
254
- raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
255
- "Did you mean (#{(type[:type] || type["type"]).inspect}, #{(type[:title] || type["title"]).inspect }) ?"
254
+ #TRANSLATORS 'Puppet::Resource.new' should not be translated
255
+ raise ArgumentError, _("Puppet::Resource.new does not take a hash as the first argument.") + ' ' +
256
+ _("Did you mean (%{type}, %{title}) ?") %
257
+ { type: (type[:type] || type["type"]).inspect, title: (type[:title] || type["title"]).inspect }
256
258
  end
257
259
 
258
260
  # In order to avoid an expensive search of 'known_resource_types" and
@@ -288,9 +290,9 @@ class Puppet::Resource
288
290
 
289
291
  if strict? && rt.nil?
290
292
  if self.class?
291
- raise ArgumentError, "Could not find declared class #{title}"
293
+ raise ArgumentError, _("Could not find declared class %{title}") % { title: title }
292
294
  else
293
- raise ArgumentError, "Invalid resource type #{type}"
295
+ raise ArgumentError, _("Invalid resource type %{type}") % { type: type }
294
296
  end
295
297
  end
296
298
 
@@ -587,7 +589,7 @@ class Puppet::Resource
587
589
  elsif argtitle.nil? && argtype =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
588
590
  elsif argtitle then [ argtype, argtitle ]
589
591
  elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
590
- else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
592
+ else raise ArgumentError, _("No title provided and %{type} is not a valid resource reference") % { type: argtype.inspect }
591
593
  end
592
594
  end
593
595
  private_class_method :extract_type_and_title
@@ -23,7 +23,8 @@ module Puppet::Resource::CapabilityFinder
23
23
  # @return [Puppet::Resource,nil] The found capability resource or `nil` if it could not be found
24
24
  def self.find(environment, code_id, cap)
25
25
  unless Puppet::Util.const_defined?('Puppetdb')
26
- raise Puppet::DevError, 'PuppetDB is not available'
26
+ #TRANSLATOR PuppetDB is a product name and should not be translated
27
+ raise Puppet::DevError, _('PuppetDB is not available')
27
28
  end
28
29
 
29
30
  resources = search(nil, nil, cap)
@@ -40,10 +41,11 @@ module Puppet::Resource::CapabilityFinder
40
41
  elsif code_id_resource = disambiguate_by_code_id(environment, code_id, cap)
41
42
  resource_hash = code_id_resource
42
43
  else
43
- raise Puppet::DevError,
44
- "Unexpected response from PuppetDB when looking up #{cap}:\n" \
45
- "expected exactly one resource but got #{resources.size};\n" \
46
- "returned data is:\n#{resources.inspect}"
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
47
49
  end
48
50
 
49
51
  if resource_hash
@@ -72,7 +74,8 @@ module Puppet::Resource::CapabilityFinder
72
74
  ['=', 'code_id', code_id]]]]
73
75
  end
74
76
 
75
- Puppet.notice _("Looking up capability %{cap} in PuppetDB: %{query_terms}") % { cap: cap, query_terms: query_terms }
77
+ #TRANSLATOR PuppetDB is a product name and should not be translated
78
+ Puppet.notice _("Looking up capability %{capability} in PuppetDB: %{query_terms}") % { capability: cap, query_terms: query_terms }
76
79
 
77
80
  query_puppetdb(query_terms)
78
81
  end
@@ -95,15 +98,15 @@ module Puppet::Resource::CapabilityFinder
95
98
  # The format of the response body is documented at
96
99
  # https://docs.puppetlabs.com/puppetdb/3.0/api/query/v4/resources.html#response-format
97
100
  unless result.is_a?(Array)
98
- raise Puppet::DevError,
99
- "Unexpected response from PuppetDB when looking up #{cap}: " \
100
- "expected an Array but got #{result.inspect}"
101
+ #TRANSLATOR PuppetDB is a product name and should not be translated
102
+ raise Puppet::DevError, _("Unexpected response from PuppetDB when looking up %{capability}: expected an Array but got %{result}") %
103
+ { capability: cap, result: result.inspect }
101
104
  end
102
105
 
103
106
  result
104
107
  rescue JSON::JSONError => e
105
- raise Puppet::DevError,
106
- "Invalid JSON from PuppetDB when looking up #{cap}\n#{e}"
108
+ #TRANSLATOR PuppetDB is a product name and should not be translated
109
+ raise Puppet::DevError, _("Invalid JSON from PuppetDB when looking up %{capability}\n%{detail}") % { capability: cap, detail: e }
107
110
  end
108
111
  end
109
112
 
@@ -100,7 +100,10 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
100
100
  resources.each do |resource|
101
101
  other_title_key = title_key_for_ref(other.ref)
102
102
  idx = @resources.index(other_title_key)
103
- raise ArgumentError, "Cannot add resource #{resource.ref} before #{other.ref} because #{other.ref} is not yet in the catalog" if idx.nil?
103
+ if idx.nil?
104
+ raise ArgumentError, _("Cannot add resource %{resource_1} before %{resource_2} because %{resource_2} is not yet in the catalog") %
105
+ { resource_1: resource.ref, resource_2: other.ref }
106
+ end
104
107
  add_one_resource(resource, idx)
105
108
  end
106
109
  end
@@ -112,7 +115,10 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
112
115
  resources.each do |resource|
113
116
  other_title_key = title_key_for_ref(other.ref)
114
117
  idx = @resources.index(other_title_key)
115
- raise ArgumentError, "Cannot add resource #{resource.ref} after #{other.ref} because #{other.ref} is not yet in the catalog" if idx.nil?
118
+ if idx.nil?
119
+ raise ArgumentError, _("Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog") %
120
+ { resource_1: resource.ref, resource_2: other.ref }
121
+ end
116
122
  add_one_resource(resource, idx+1)
117
123
  end
118
124
  end
@@ -193,10 +199,17 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
193
199
  # isn't sufficient.
194
200
  if existing = @resource_table[newref]
195
201
  return if existing == resource
196
- resource_declaration = " at #{resource.file}:#{resource.line}" if resource.file and resource.line
197
- existing_declaration = " at #{existing.file}:#{existing.line}" if existing.file and existing.line
198
- #TRANSLATORS "resource" here is a Puppet type and should not be translated
199
- msg = _("Cannot alias %{ref} to %{key}%{resource_declaration}; resource %{newref} already declared%{existing_declaration}") % { ref: ref, key: key.inspect, resource_declaration: resource_declaration, newref: newref.inspect, existing_declaration: existing_declaration }
202
+ resource_declaration = Puppet::Util::Errors.error_location(resource.file, resource.line)
203
+ msg = if resource_declaration.empty?
204
+ #TRANSLATORS 'alias' should not be translated
205
+ _("Cannot alias %{resource} to %{key}; resource %{newref} already declared") %
206
+ { resource: ref, key: key.inspect, newref: newref.inspect }
207
+ else
208
+ #TRANSLATORS 'alias' should not be translated
209
+ _("Cannot alias %{resource} to %{key} at %{resource_declaration}; resource %{newref} already declared") %
210
+ { resource: ref, key: key.inspect, resource_declaration: resource_declaration, newref: newref.inspect }
211
+ end
212
+ msg += Puppet::Util::Errors.error_location_with_space(existing.file, existing.line)
200
213
  raise ArgumentError, msg
201
214
  end
202
215
  @resource_table[newref] = resource
@@ -271,7 +284,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
271
284
  # Create a new resource and register it in the catalog.
272
285
  def create_resource(type, options)
273
286
  unless klass = Puppet::Type.type(type)
274
- raise ArgumentError, "Unknown resource type #{type}"
287
+ raise ArgumentError, _("Unknown resource type %{type}") % { type: type }
275
288
  end
276
289
  return unless resource = klass.new(options)
277
290
 
@@ -433,12 +446,14 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
433
446
  edges.each do |edge_hash|
434
447
  edge = Puppet::Relationship.from_data_hash(edge_hash)
435
448
  unless source = result.resource(edge.source)
436
- raise ArgumentError, "Could not intern from data: Could not find relationship source #{edge.source.inspect} for #{edge.target.to_s}"
449
+ raise ArgumentError, _("Could not intern from data: Could not find relationship source %{source} for %{target}") %
450
+ { source: edge.source.inspect, target: edge.target.to_s }
437
451
  end
438
452
  edge.source = source
439
453
 
440
454
  unless target = result.resource(edge.target)
441
- raise ArgumentError, "Could not intern from data: Could not find relationship target #{edge.target.inspect} for #{edge.source.to_s}"
455
+ raise ArgumentError, _("Could not intern from data: Could not find relationship target %{target} for %{source}") %
456
+ { target: edge.target.inspect, source: edge.source.to_s }
442
457
  end
443
458
  edge.target = target
444
459
 
@@ -572,7 +587,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
572
587
  when "random"
573
588
  Puppet::Graph::RandomPrioritizer.new
574
589
  else
575
- raise Puppet::DevError, "Unknown ordering type #{Puppet[:ordering]}"
590
+ raise Puppet::DevError, _("Unknown ordering type %{ordering}") % { ordering: Puppet[:ordering] }
576
591
  end
577
592
  end
578
593
 
@@ -591,12 +606,12 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
591
606
  return unless existing_resource = @resource_table[title_key]
592
607
 
593
608
  # If we've gotten this far, it's a real conflict
594
- msg = "Duplicate declaration: #{resource.ref} is already declared"
595
-
596
- msg << " in file #{existing_resource.file}:#{existing_resource.line}" if existing_resource.file and existing_resource.line
597
-
598
- msg << "; cannot redeclare"
599
-
609
+ error_location_str = Puppet::Util::Errors.error_location(existing_resource.file, existing_resource.line)
610
+ msg = if error_location_str.empty?
611
+ _("Duplicate declaration: %{resource} is already declared; cannot redeclare") % { resource: resource.ref }
612
+ else
613
+ _("Duplicate declaration: %{resource} is already declared at %{error_location}; cannot redeclare") % { resource: resource.ref, error_location: error_location_str }
614
+ end
600
615
  raise DuplicateResourceError.new(msg, resource.file, resource.line)
601
616
  end
602
617
 
@@ -643,11 +658,11 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
643
658
  next if block_given? and yield edge.target
644
659
 
645
660
  unless source = map[edge.source.ref]
646
- raise Puppet::DevError, "Could not find resource #{edge.source.ref} when converting #{message} resources"
661
+ raise Puppet::DevError, _("Could not find resource %{resource} when converting %{message} resources") % { resource: edge.source.ref, message: message }
647
662
  end
648
663
 
649
664
  unless target = map[edge.target.ref]
650
- raise Puppet::DevError, "Could not find resource #{edge.target.ref} when converting #{message} resources"
665
+ raise Puppet::DevError, _("Could not find resource %{resource} when converting %{message} resources") % { resource: edge.target.ref, message: message }
651
666
  end
652
667
 
653
668
  result.add_edge(source, target, edge.label)
@@ -140,7 +140,7 @@ class Puppet::Resource::Type
140
140
 
141
141
  def initialize(type, name, options = {})
142
142
  @type = type.to_s.downcase.to_sym
143
- raise ArgumentError, "Invalid resource supertype '#{type}'" unless RESOURCE_KINDS.include?(@type)
143
+ raise ArgumentError, _("Invalid resource supertype '%{type}'") % { type: type } unless RESOURCE_KINDS.include?(@type)
144
144
 
145
145
  name = convert_from_ast(name) if name.is_a?(Puppet::Parser::AST::HostName)
146
146
 
@@ -223,7 +223,7 @@ class Puppet::Resource::Type
223
223
  resource_type =
224
224
  case type
225
225
  when :definition
226
- raise ArgumentError, 'Cannot create resources for defined resource types'
226
+ raise ArgumentError, _('Cannot create resources for defined resource types')
227
227
  when :hostclass
228
228
  :class
229
229
  when :node
@@ -420,10 +420,10 @@ class Puppet::Resource::Type
420
420
  name_to_type_hash.each do |name, t|
421
421
  # catch internal errors
422
422
  unless @arguments.include?(name)
423
- raise Puppet::DevError, "Parameter '#{name}' is given a type, but is not a valid parameter."
423
+ raise Puppet::DevError, _("Parameter '%{name}' is given a type, but is not a valid parameter.") % { name: name }
424
424
  end
425
425
  unless t.is_a? Puppet::Pops::Types::PAnyType
426
- raise Puppet::DevError, "Parameter '#{name}' is given a type that is not a Puppet Type, got #{t.class}"
426
+ raise Puppet::DevError, _("Parameter '%{name}' is given a type that is not a Puppet Type, got %{class_name}") % { name: name, class_name: t.class }
427
427
  end
428
428
  @argument_types[name] = t
429
429
  end
@@ -463,7 +463,7 @@ class Puppet::Resource::Type
463
463
  end
464
464
 
465
465
  def parent_scope(scope, klass)
466
- scope.class_scope(klass) || raise(Puppet::DevError, "Could not find scope for #{klass.name}")
466
+ scope.class_scope(klass) || raise(Puppet::DevError, _("Could not find scope for %{class_name}") % { class_name: klass.name })
467
467
  end
468
468
 
469
469
  def set_name_and_namespace(name)
@@ -256,7 +256,7 @@ class Puppet::Settings
256
256
  end
257
257
 
258
258
  def initialize_global_settings(args = [])
259
- raise Puppet::DevError, "Attempting to initialize global default settings more than once!" if global_defaults_initialized?
259
+ raise Puppet::DevError, _("Attempting to initialize global default settings more than once!") if global_defaults_initialized?
260
260
 
261
261
  # The first two phases of the lifecycle of a puppet application are:
262
262
  # 1) Parse the command line options and handle any of them that are
@@ -686,7 +686,7 @@ class Puppet::Settings
686
686
 
687
687
  if type = hash[:type]
688
688
  unless klass = SETTING_TYPES[type]
689
- raise ArgumentError, "Invalid setting type '#{type}'"
689
+ raise ArgumentError, _("Invalid setting type '%{type}'") % { type: type }
690
690
  end
691
691
  hash.delete(:type)
692
692
  else
@@ -830,7 +830,7 @@ class Puppet::Settings
830
830
  when :environment
831
831
  ValuesFromEnvironmentConf.new(source.name)
832
832
  else
833
- raise(Puppet::DevError, "Unknown searchpath case: #{source.type} for the #{source} settings path element.")
833
+ raise Puppet::DevError, _("Unknown searchpath case: %{source_type} for the %{source} settings path element.") % { source_type: source.type, source: source}
834
834
  end
835
835
  end
836
836
 
@@ -892,16 +892,16 @@ class Puppet::Settings
892
892
  section = section.to_sym
893
893
  call = []
894
894
  defs.each do |name, hash|
895
- raise ArgumentError, "setting definition for '#{name}' is not a hash!" unless hash.is_a? Hash
895
+ raise ArgumentError, _("setting definition for '%{name}' is not a hash!") % { name: name } unless hash.is_a? Hash
896
896
 
897
897
  name = name.to_sym
898
898
  hash[:name] = name
899
899
  hash[:section] = section
900
- raise ArgumentError, "Setting #{name} is already defined" if @config.include?(name)
900
+ raise ArgumentError, _("Setting %{name} is already defined") % { name: name } if @config.include?(name)
901
901
  tryconfig = newsetting(hash)
902
902
  if short = tryconfig.short
903
903
  if other = @shortnames[short]
904
- raise ArgumentError, "Setting #{other.name} is already using short name '#{short}'"
904
+ raise ArgumentError, _("Setting %{name} is already using short name '%{short}'") % { name: other.name, short: short }
905
905
  end
906
906
  @shortnames[short] = tryconfig
907
907
  end
@@ -1158,9 +1158,14 @@ Generated on #{Time.now}.
1158
1158
  msg << " #{ref}" if ref
1159
1159
  Puppet.deprecation_warning(msg)
1160
1160
  when setting.completely_deprecated?
1161
- Puppet.deprecation_warning("Setting #{name} is deprecated. #{ref}", "setting-#{name}")
1161
+ message = _("Setting %{name} is deprecated.") % { name: name }
1162
+ message += " #{ref}"
1163
+ Puppet.deprecation_warning(message, "setting-#{name}")
1162
1164
  when setting.allowed_on_commandline?
1163
- Puppet.deprecation_warning("Setting #{name} is deprecated in puppet.conf. #{ref}", "puppet-conf-setting-#{name}")
1165
+ #TRANSLATORS 'puppet.conf' is a file name and should not be translated
1166
+ message = _("Setting %{name} is deprecated in puppet.conf.") % { name: name }
1167
+ message += " #{ref}"
1168
+ Puppet.deprecation_warning(message, "puppet-conf-setting-#{name}")
1164
1169
  end
1165
1170
  end
1166
1171
 
@@ -1304,7 +1309,7 @@ Generated on #{Time.now}.
1304
1309
  rescue InterpolationError => err
1305
1310
  # This happens because we don't have access to the param name when the
1306
1311
  # exception is originally raised, but we want it in the message
1307
- raise InterpolationError, "Error converting value for param '#{name}': #{err}", err.backtrace
1312
+ raise InterpolationError, _("Error converting value for param '%{name}': %{detail}") % { name: name, detail: err }, err.backtrace
1308
1313
  end
1309
1314
 
1310
1315
  setting.munge(val)
@@ -1333,7 +1338,7 @@ Generated on #{Time.now}.
1333
1338
  elsif !(pval = interpolate(varname.to_sym)).nil?
1334
1339
  pval
1335
1340
  else
1336
- raise InterpolationError, "Could not find value for #{expression}"
1341
+ raise InterpolationError, _("Could not find value for %{expression}") % { expression: expression }
1337
1342
  end
1338
1343
  else
1339
1344
  failed_environment_interpolation = true
@@ -1342,7 +1347,9 @@ Generated on #{Time.now}.
1342
1347
  interpolated_expression
1343
1348
  end
1344
1349
  if failed_environment_interpolation
1345
- Puppet.warning("You cannot interpolate $environment within '#{setting_name}' when using directory environments. Its value will remain #{interpolated_value}.")
1350
+ #TRANSLATORS '$environment' is a Puppet specific variable and should not be translated
1351
+ Puppet.warning(_("You cannot interpolate $environment within '%{setting_name}' when using directory environments.") % { setting_name: setting_name } +
1352
+ ' ' + _("Its value will remain %{value}.") % { value: interpolated_value })
1346
1353
  end
1347
1354
  interpolated_value
1348
1355
  else
@@ -1373,8 +1380,7 @@ Generated on #{Time.now}.
1373
1380
  default = @defaults[name]
1374
1381
 
1375
1382
  if !default
1376
- raise ArgumentError,
1377
- "Attempt to assign a value to unknown setting #{name.inspect}"
1383
+ raise ArgumentError, _("Attempt to assign a value to unknown setting %{name}") % { name: name.inspect }
1378
1384
  end
1379
1385
 
1380
1386
  # This little exception-handling dance ensures that a hook is