bolt 0.17.1 → 0.17.2

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 (224) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +25 -13
  3. data/lib/bolt/cli.rb +45 -15
  4. data/lib/bolt/config.rb +48 -132
  5. data/lib/bolt/executor.rb +3 -10
  6. data/lib/bolt/inventory.rb +15 -1
  7. data/lib/bolt/puppetdb.rb +11 -0
  8. data/lib/bolt/puppetdb/client.rb +68 -0
  9. data/lib/bolt/puppetdb/config.rb +76 -0
  10. data/lib/bolt/target.rb +5 -4
  11. data/lib/bolt/transport/base.rb +11 -2
  12. data/lib/bolt/transport/local.rb +11 -5
  13. data/lib/bolt/transport/orch.rb +16 -5
  14. data/lib/bolt/transport/ssh.rb +32 -1
  15. data/lib/bolt/transport/ssh/connection.rb +17 -10
  16. data/lib/bolt/transport/winrm.rb +18 -1
  17. data/lib/bolt/transport/winrm/connection.rb +15 -16
  18. data/lib/bolt/util.rb +15 -0
  19. data/lib/bolt/version.rb +1 -1
  20. data/lib/bolt_ext/puppetdb_inventory.rb +5 -135
  21. data/vendored/facter/lib/facter/ec2/rest.rb +1 -1
  22. data/vendored/hiera/lib/hiera/version.rb +1 -1
  23. data/vendored/puppet/lib/puppet/application/agent.rb +1 -3
  24. data/vendored/puppet/lib/puppet/application/apply.rb +2 -4
  25. data/vendored/puppet/lib/puppet/application/cert.rb +6 -1
  26. data/vendored/puppet/lib/puppet/application/device.rb +100 -13
  27. data/vendored/puppet/lib/puppet/application/facts.rb +5 -0
  28. data/vendored/puppet/lib/puppet/application/lookup.rb +11 -1
  29. data/vendored/puppet/lib/puppet/configurer.rb +17 -4
  30. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
  31. data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
  32. data/vendored/puppet/lib/puppet/defaults.rb +1 -1
  33. data/vendored/puppet/lib/puppet/environments.rb +2 -2
  34. data/vendored/puppet/lib/puppet/error.rb +6 -3
  35. data/vendored/puppet/lib/puppet/external/dot.rb +0 -7
  36. data/vendored/puppet/lib/puppet/external/nagios/parser.rb +1 -1
  37. data/vendored/puppet/lib/puppet/face/config.rb +41 -8
  38. data/vendored/puppet/lib/puppet/face/epp.rb +30 -5
  39. data/vendored/puppet/lib/puppet/face/facts.rb +49 -0
  40. data/vendored/puppet/lib/puppet/face/help.rb +33 -35
  41. data/vendored/puppet/lib/puppet/face/man.rb +55 -12
  42. data/vendored/puppet/lib/puppet/face/parser.rb +30 -3
  43. data/vendored/puppet/lib/puppet/file_bucket/file.rb +0 -2
  44. data/vendored/puppet/lib/puppet/file_serving/base.rb +10 -10
  45. data/vendored/puppet/lib/puppet/functions.rb +1 -3
  46. data/vendored/puppet/lib/puppet/functions/alert.rb +1 -1
  47. data/vendored/puppet/lib/puppet/functions/all.rb +6 -6
  48. data/vendored/puppet/lib/puppet/functions/annotate.rb +10 -10
  49. data/vendored/puppet/lib/puppet/functions/any.rb +6 -6
  50. data/vendored/puppet/lib/puppet/functions/assert_type.rb +4 -4
  51. data/vendored/puppet/lib/puppet/functions/binary_file.rb +14 -2
  52. data/vendored/puppet/lib/puppet/functions/break.rb +31 -2
  53. data/vendored/puppet/lib/puppet/functions/call.rb +4 -4
  54. data/vendored/puppet/lib/puppet/functions/contain.rb +19 -3
  55. data/vendored/puppet/lib/puppet/functions/convert_to.rb +6 -5
  56. data/vendored/puppet/lib/puppet/functions/crit.rb +1 -1
  57. data/vendored/puppet/lib/puppet/functions/debug.rb +1 -1
  58. data/vendored/puppet/lib/puppet/functions/defined.rb +11 -9
  59. data/vendored/puppet/lib/puppet/functions/dig.rb +26 -2
  60. data/vendored/puppet/lib/puppet/functions/each.rb +8 -8
  61. data/vendored/puppet/lib/puppet/functions/emerg.rb +1 -1
  62. data/vendored/puppet/lib/puppet/functions/empty.rb +79 -0
  63. data/vendored/puppet/lib/puppet/functions/err.rb +1 -1
  64. data/vendored/puppet/lib/puppet/functions/filter.rb +7 -7
  65. data/vendored/puppet/lib/puppet/functions/find_file.rb +15 -1
  66. data/vendored/puppet/lib/puppet/functions/flatten.rb +64 -0
  67. data/vendored/puppet/lib/puppet/functions/hiera.rb +6 -6
  68. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +6 -6
  69. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
  70. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +8 -8
  71. data/vendored/puppet/lib/puppet/functions/include.rb +28 -2
  72. data/vendored/puppet/lib/puppet/functions/info.rb +1 -1
  73. data/vendored/puppet/lib/puppet/functions/inline_epp.rb +2 -2
  74. data/vendored/puppet/lib/puppet/functions/join.rb +56 -0
  75. data/vendored/puppet/lib/puppet/functions/keys.rb +25 -0
  76. data/vendored/puppet/lib/puppet/functions/length.rb +44 -0
  77. data/vendored/puppet/lib/puppet/functions/lest.rb +39 -1
  78. data/vendored/puppet/lib/puppet/functions/map.rb +10 -9
  79. data/vendored/puppet/lib/puppet/functions/match.rb +6 -6
  80. data/vendored/puppet/lib/puppet/functions/new.rb +995 -2
  81. data/vendored/puppet/lib/puppet/functions/next.rb +1 -1
  82. data/vendored/puppet/lib/puppet/functions/notice.rb +1 -1
  83. data/vendored/puppet/lib/puppet/functions/reduce.rb +6 -6
  84. data/vendored/puppet/lib/puppet/functions/regsubst.rb +9 -3
  85. data/vendored/puppet/lib/puppet/functions/require.rb +36 -2
  86. data/vendored/puppet/lib/puppet/functions/return.rb +1 -1
  87. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +71 -2
  88. data/vendored/puppet/lib/puppet/functions/slice.rb +23 -9
  89. data/vendored/puppet/lib/puppet/functions/split.rb +12 -10
  90. data/vendored/puppet/lib/puppet/functions/step.rb +73 -1
  91. data/vendored/puppet/lib/puppet/functions/strftime.rb +176 -2
  92. data/vendored/puppet/lib/puppet/functions/then.rb +65 -2
  93. data/vendored/puppet/lib/puppet/functions/tree_each.rb +19 -19
  94. data/vendored/puppet/lib/puppet/functions/type.rb +42 -1
  95. data/vendored/puppet/lib/puppet/functions/unique.rb +13 -13
  96. data/vendored/puppet/lib/puppet/functions/unwrap.rb +8 -4
  97. data/vendored/puppet/lib/puppet/functions/values.rb +25 -0
  98. data/vendored/puppet/lib/puppet/functions/versioncmp.rb +1 -1
  99. data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
  100. data/vendored/puppet/lib/puppet/functions/with.rb +6 -4
  101. data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +1 -1
  102. data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +1 -3
  103. data/vendored/puppet/lib/puppet/indirector/facts/rest.rb +21 -0
  104. data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +0 -4
  105. data/vendored/puppet/lib/puppet/indirector/file_content/http.rb +3 -1
  106. data/vendored/puppet/lib/puppet/indirector/indirection.rb +5 -3
  107. data/vendored/puppet/lib/puppet/indirector/request.rb +6 -2
  108. data/vendored/puppet/lib/puppet/module/task.rb +2 -2
  109. data/vendored/puppet/lib/puppet/module_tool/tar/mini.rb +57 -4
  110. data/vendored/puppet/lib/puppet/network/authconfig.rb +1 -1
  111. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -0
  112. data/vendored/puppet/lib/puppet/network/resolver.rb +1 -2
  113. data/vendored/puppet/lib/puppet/node.rb +4 -3
  114. data/vendored/puppet/lib/puppet/parser/compiler.rb +12 -5
  115. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +1 -1
  116. data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +15 -4
  117. data/vendored/puppet/lib/puppet/parser/functions/new.rb +31 -46
  118. data/vendored/puppet/lib/puppet/parser/parser_factory.rb +1 -1
  119. data/vendored/puppet/lib/puppet/parser/resource.rb +1 -1
  120. data/vendored/puppet/lib/puppet/parser/type_loader.rb +11 -11
  121. data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
  122. data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +1 -1
  123. data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +2 -2
  124. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -2
  125. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -2
  126. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
  127. data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +18 -1
  128. data/vendored/puppet/lib/puppet/pops/issues.rb +6 -3
  129. data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +1 -2
  130. data/vendored/puppet/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -2
  131. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +4 -4
  132. data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -1
  133. data/vendored/puppet/lib/puppet/pops/loaders.rb +18 -7
  134. data/vendored/puppet/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
  135. data/vendored/puppet/lib/puppet/pops/model/factory.rb +6 -3
  136. data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
  137. data/vendored/puppet/lib/puppet/pops/model/pn_transformer.rb +400 -0
  138. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1 -1
  139. data/vendored/puppet/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  140. data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +3 -2
  141. data/vendored/puppet/lib/puppet/pops/parser/locator.rb +0 -2
  142. data/vendored/puppet/lib/puppet/pops/parser/pn_parser.rb +316 -0
  143. data/vendored/puppet/lib/puppet/pops/pcore.rb +17 -17
  144. data/vendored/puppet/lib/puppet/pops/pn.rb +236 -0
  145. data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  146. data/vendored/puppet/lib/puppet/pops/types/class_loader.rb +6 -3
  147. data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +28 -35
  148. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -3
  149. data/vendored/puppet/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  150. data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +24 -1
  151. data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +3 -4
  152. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +1 -1
  153. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +0 -4
  154. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
  155. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +14 -7
  156. data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -1
  157. data/vendored/puppet/lib/puppet/pops/utils.rb +2 -2
  158. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +6 -2
  159. data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +3 -1
  160. data/vendored/puppet/lib/puppet/provider/group/windows_adsi.rb +4 -7
  161. data/vendored/puppet/lib/puppet/provider/nameservice.rb +3 -3
  162. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +1 -1
  163. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  164. data/vendored/puppet/lib/puppet/provider/package/pacman.rb +4 -4
  165. data/vendored/puppet/lib/puppet/provider/package/pip.rb +3 -3
  166. data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +3 -3
  167. data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +2 -2
  168. data/vendored/puppet/lib/puppet/provider/package/portage.rb +9 -9
  169. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
  170. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  171. data/vendored/puppet/lib/puppet/provider/service/smf.rb +3 -2
  172. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +6 -2
  173. data/vendored/puppet/lib/puppet/provider/user/windows_adsi.rb +1 -1
  174. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +3 -2
  175. data/vendored/puppet/lib/puppet/reference/configuration.rb +2 -0
  176. data/vendored/puppet/lib/puppet/reference/type.rb +11 -11
  177. data/vendored/puppet/lib/puppet/resource.rb +1 -1
  178. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +2 -2
  179. data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -2
  180. data/vendored/puppet/lib/puppet/resource/status.rb +9 -2
  181. data/vendored/puppet/lib/puppet/resource/type.rb +1 -1
  182. data/vendored/puppet/lib/puppet/settings.rb +31 -19
  183. data/vendored/puppet/lib/puppet/settings/base_setting.rb +5 -0
  184. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
  185. data/vendored/puppet/lib/puppet/settings/ttl_setting.rb +5 -0
  186. data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +2 -2
  187. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +0 -2
  188. data/vendored/puppet/lib/puppet/transaction/additional_resource_generator.rb +2 -2
  189. data/vendored/puppet/lib/puppet/transaction/event.rb +1 -1
  190. data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
  191. data/vendored/puppet/lib/puppet/type.rb +9 -13
  192. data/vendored/puppet/lib/puppet/type/augeas.rb +2 -2
  193. data/vendored/puppet/lib/puppet/type/cron.rb +11 -6
  194. data/vendored/puppet/lib/puppet/type/exec.rb +1 -1
  195. data/vendored/puppet/lib/puppet/type/file.rb +4 -5
  196. data/vendored/puppet/lib/puppet/type/host.rb +1 -1
  197. data/vendored/puppet/lib/puppet/type/k5login.rb +30 -54
  198. data/vendored/puppet/lib/puppet/type/package.rb +3 -3
  199. data/vendored/puppet/lib/puppet/type/schedule.rb +12 -12
  200. data/vendored/puppet/lib/puppet/type/scheduled_task.rb +2 -2
  201. data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +5 -5
  202. data/vendored/puppet/lib/puppet/type/sshkey.rb +2 -2
  203. data/vendored/puppet/lib/puppet/type/tidy.rb +9 -2
  204. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  205. data/vendored/puppet/lib/puppet/type/yumrepo.rb +25 -4
  206. data/vendored/puppet/lib/puppet/type/zfs.rb +4 -0
  207. data/vendored/puppet/lib/puppet/util.rb +0 -4
  208. data/vendored/puppet/lib/puppet/util/backups.rb +1 -1
  209. data/vendored/puppet/lib/puppet/util/http_proxy.rb +4 -2
  210. data/vendored/puppet/lib/puppet/util/inifile.rb +3 -4
  211. data/vendored/puppet/lib/puppet/util/log.rb +2 -5
  212. data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  213. data/vendored/puppet/lib/puppet/util/reference.rb +1 -8
  214. data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
  215. data/vendored/puppet/lib/puppet/util/warnings.rb +0 -2
  216. data/vendored/puppet/lib/puppet/util/windows/adsi.rb +15 -18
  217. data/vendored/puppet/lib/puppet/util/windows/com.rb +2 -1
  218. data/vendored/puppet/lib/puppet/util/windows/file.rb +2 -2
  219. data/vendored/puppet/lib/puppet/util/windows/principal.rb +7 -6
  220. data/vendored/puppet/lib/puppet/util/windows/sid.rb +60 -7
  221. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -9
  222. data/vendored/puppet/lib/puppet/version.rb +1 -1
  223. data/vendored/puppet/lib/puppet_pal.rb +53 -48
  224. metadata +15 -2
@@ -1,4 +1,9 @@
1
1
  require 'puppet/application/indirection_base'
2
2
 
3
3
  class Puppet::Application::Facts < Puppet::Application::IndirectionBase
4
+ # Allows `puppet facts` actions to be run against environments that
5
+ # don't exist locally, such as using the `--environment` flag to make a REST
6
+ # request to a specific environment on a master. There is no way to set this
7
+ # behavior per-action, so it must be set for the face as a whole.
8
+ environment_mode :not_required
4
9
  end
@@ -335,7 +335,17 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
335
335
  Puppet.settings[:facts_terminus] = 'facter'
336
336
  end
337
337
 
338
- node = Puppet::Node.indirection.find(node) unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
338
+ unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
339
+ ni = Puppet::Node.indirection
340
+ tc = ni.terminus_class
341
+ if tc == :plain || options[:compile]
342
+ node = ni.find(node)
343
+ else
344
+ ni.terminus_class = :plain
345
+ node = ni.find(node)
346
+ ni.terminus_class = tc
347
+ end
348
+ end
339
349
 
340
350
  fact_file = options[:fact_file]
341
351
 
@@ -424,8 +424,13 @@ class Puppet::Configurer
424
424
  def retrieve_catalog_from_cache(query_options)
425
425
  result = nil
426
426
  @duration = thinmark do
427
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
428
- query_options.merge(:ignore_terminus => true, :environment => Puppet::Node::Environment.remote(@environment)))
427
+ result = Puppet::Resource::Catalog.indirection.find(
428
+ Puppet[:node_name_value],
429
+ query_options.merge(
430
+ :ignore_terminus => true,
431
+ :environment => Puppet::Node::Environment.remote(@environment)
432
+ )
433
+ )
429
434
  end
430
435
  result
431
436
  rescue => detail
@@ -436,8 +441,16 @@ class Puppet::Configurer
436
441
  def retrieve_new_catalog(query_options)
437
442
  result = nil
438
443
  @duration = thinmark do
439
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
440
- query_options.merge(:ignore_cache => true, :environment => Puppet::Node::Environment.remote(@environment), :fail_on_404 => true))
444
+ result = Puppet::Resource::Catalog.indirection.find(
445
+ Puppet[:node_name_value],
446
+ query_options.merge(
447
+ :ignore_cache => true,
448
+ # We never want to update the cached Catalog if we're running in noop mode.
449
+ :ignore_cache_save => Puppet[:noop],
450
+ :environment => Puppet::Node::Environment.remote(@environment),
451
+ :fail_on_404 => true
452
+ )
453
+ )
441
454
  end
442
455
  result
443
456
  rescue StandardError => detail
@@ -35,7 +35,7 @@ class Puppet::Configurer::PluginHandler
35
35
  "locales",
36
36
  Puppet[:localedest],
37
37
  Puppet[:localesource],
38
- Puppet[:localeignore],
38
+ Puppet[:pluginsignore] + " *.pot config.yaml",
39
39
  environment
40
40
  )
41
41
  result += locales_downloader.evaluate
@@ -169,7 +169,7 @@ module Puppet::DataTypes
169
169
  end
170
170
  end
171
171
  else
172
- Puppet::Pops::Loaders.implementation_registry.register_implementation(created_type, @implementation_class, loader)
172
+ Puppet::Pops::Loaders.implementation_registry.register_implementation(created_type, @implementation_class)
173
173
  end
174
174
  created_type.implementation_class = @implementation_class
175
175
  elsif !@implementation.nil?
@@ -1820,7 +1820,7 @@ EOT
1820
1820
  }
1821
1821
  },
1822
1822
  :pluginsignore => {
1823
- :default => ".svn CVS .git .hg *.pot",
1823
+ :default => ".svn CVS .git .hg",
1824
1824
  :desc => "What files to ignore when pulling down plugins.",
1825
1825
  }
1826
1826
  )
@@ -115,7 +115,7 @@ module Puppet::Environments
115
115
  def get_conf(name)
116
116
  env = get(name)
117
117
  if env
118
- Puppet::Settings::EnvironmentConf.static_for(env, 0, Puppet[:static_catalogs], Puppet[:rich_data])
118
+ Puppet::Settings::EnvironmentConf.static_for(env, Puppet[:environment_timeout], Puppet[:static_catalogs], Puppet[:rich_data])
119
119
  else
120
120
  nil
121
121
  end
@@ -314,7 +314,7 @@ module Puppet::Environments
314
314
  end
315
315
 
316
316
  # Returns the end of time (the next Mesoamerican Long Count cycle-end after 2012 (5125+2012) = 7137,
317
- # of for a 32 bit machine using Ruby < 1.9.3, the year 2038.
317
+ # or for a 32 bit machine using Ruby < 1.9.3, the year 2038.
318
318
  def self.end_of_time
319
319
  begin
320
320
  Time.gm(7137)
@@ -46,7 +46,7 @@ module Puppet
46
46
 
47
47
  # Contains an issue code and can be annotated with an environment and a node
48
48
  class ParseErrorWithIssue < Puppet::ParseError
49
- attr_reader :issue_code, :basic_message
49
+ attr_reader :issue_code, :basic_message, :arguments
50
50
  attr_accessor :environment, :node
51
51
 
52
52
  # @param message [String] The error message
@@ -55,11 +55,13 @@ module Puppet
55
55
  # @param pos [Integer] The position on the line
56
56
  # @param original [Exception] Original exception
57
57
  # @param issue_code [Symbol] The issue code
58
+ # @param arguments [Hash{Symbol=>Object}] Issue arguments
58
59
  #
59
- def initialize(message, file=nil, line=nil, pos=nil, original=nil, issue_code= nil)
60
+ def initialize(message, file=nil, line=nil, pos=nil, original=nil, issue_code= nil, arguments = nil)
60
61
  super(message, file, line, pos, original)
61
62
  @issue_code = issue_code
62
63
  @basic_message = message
64
+ @arguments = arguments
63
65
  end
64
66
 
65
67
  def to_s
@@ -83,7 +85,8 @@ module Puppet
83
85
  line,
84
86
  nil,
85
87
  nil,
86
- issue.issue_code)
88
+ issue.issue_code,
89
+ args)
87
90
  end
88
91
  end
89
92
 
@@ -181,9 +181,6 @@ module DOT
181
181
  # node element
182
182
 
183
183
  class DOTNode < DOTElement
184
-
185
- @ports
186
-
187
184
  def initialize (params = {}, option_list = NODE_OPTS)
188
185
  super(params, option_list)
189
186
  @ports = params['ports'] ? params['ports'] : []
@@ -235,10 +232,6 @@ module DOT
235
232
  # notation.
236
233
 
237
234
  class DOTSubgraph < DOTElement
238
-
239
- @nodes
240
- @dot_string
241
-
242
235
  def initialize (params = {}, option_list = GRAPH_OPTS)
243
236
  super(params, option_list)
244
237
  @nodes = params['nodes'] ? params['nodes'] : []
@@ -397,4 +397,4 @@ def _reduce_none(val, _values, result)
397
397
  end
398
398
 
399
399
  end # class Parser
400
- end # module Nagios
400
+ end # module Nagios
@@ -56,8 +56,9 @@ Puppet::Face.define(:config, '0.0.1') do
56
56
 
57
57
  when_invoked do |*args|
58
58
  options = args.pop
59
+ render_all_settings = args.empty? || args == ['all']
59
60
 
60
- args = Puppet.settings.to_a.collect(&:first) if args.empty? || args == ['all']
61
+ args = Puppet.settings.to_a.collect(&:first) if render_all_settings
61
62
 
62
63
  values_from_the_selected_section =
63
64
  Puppet.settings.values(nil, options[:section].to_sym)
@@ -67,21 +68,53 @@ Puppet::Face.define(:config, '0.0.1') do
67
68
  :basemodulepath => values_from_the_selected_section.interpolate(:basemodulepath),
68
69
  }
69
70
 
71
+ to_be_rendered = nil
70
72
  Puppet.override(Puppet.base_context(loader_settings),
71
73
  _("New environment loaders generated from the requested section.")) do
72
74
  # And now we can lookup values that include those from environments configured from
73
75
  # the requested section
74
76
  values = Puppet.settings.values(Puppet[:environment].to_sym, options[:section].to_sym)
75
- if args.length == 1
76
- puts values.interpolate(args[0].to_sym)
77
- else
78
- args.sort.each do |setting_name|
79
- puts "#{setting_name} = #{values.interpolate(setting_name.to_sym)}"
80
- end
77
+
78
+ to_be_rendered = {}
79
+ args.sort.each do |setting_name|
80
+ to_be_rendered[setting_name] = values.print(setting_name.to_sym)
81
81
  end
82
82
  end
83
- nil
83
+
84
+ # convert symbols to strings before formatting output
85
+ if render_all_settings
86
+ to_be_rendered = stringifyhash(to_be_rendered)
87
+ end
88
+ to_be_rendered
89
+ end
90
+
91
+ when_rendering :console do |to_be_rendered|
92
+ output = ''
93
+ if to_be_rendered.keys.length > 1
94
+ to_be_rendered.keys.sort.each do |setting|
95
+ output << "#{setting} = #{to_be_rendered[setting]}\n"
96
+ end
97
+ else
98
+ output << "#{to_be_rendered.to_a[0].last}\n"
99
+ end
100
+
101
+ output
102
+ end
103
+ end
104
+
105
+ def stringifyhash(hash)
106
+ newhash = {}
107
+ hash.each do |key, val|
108
+ key = key.to_s
109
+ if val.is_a? Hash
110
+ newhash[key] = stringifyhash(val)
111
+ elsif val.is_a? Symbol
112
+ newhash[key] = val.to_s
113
+ else
114
+ newhash[key] = val
115
+ end
84
116
  end
117
+ newhash
85
118
  end
86
119
 
87
120
  action(:set) do
@@ -104,13 +104,19 @@ Puppet::Face.define(:epp, '0.0.1') do
104
104
 
105
105
  action (:dump) do
106
106
  summary _("Outputs a dump of the internal template parse tree for debugging")
107
- arguments "-e <source> | [<templates> ...] "
107
+ arguments "[--format <old|pn|json>] [--pretty] { -e <source> | [<templates> ...] } "
108
108
  returns _("A dump of the resulting AST model unless there are syntax or validation errors.")
109
109
  description <<-'EOT'
110
110
  The dump action parses and validates the EPP syntax and dumps the resulting AST model
111
111
  in a human readable (but not necessarily an easy to understand) format.
112
- The output format of the dumped tree is intended for epp parser debugging purposes
113
- and is not API, and may thus change between versions without deprecation warnings.
112
+
113
+ The output format can be controlled using the --format <old|pn|json> where:
114
+ * 'old' is the default, but now deprecated format which is not API.
115
+ * 'pn' is the Puppet Extended S-Expression Notation.
116
+ * 'json' outputs the same graph as 'pn' but with JSON syntax.
117
+
118
+ The output will be "pretty printed" when the option --pretty is given together with --format 'pn' or 'json'.
119
+ This option has no effect on the 'old' format.
114
120
 
115
121
  The command accepts one or more templates (.epp) files, or an -e followed by the template
116
122
  source text. The given templates can be paths to template files, or references
@@ -137,6 +143,14 @@ Puppet::Face.define(:epp, '0.0.1') do
137
143
  summary _("Whether or not to validate the parsed result, if no-validate only syntax errors are reported.")
138
144
  end
139
145
 
146
+ option('--format ' + _('<old, pn, or json>')) do
147
+ summary _("Get result in 'old' (deprecated format), 'pn' (new format), or 'json' (new format in JSON).")
148
+ end
149
+
150
+ option('--pretty') do
151
+ summary _('Pretty print output. Only applicable together with --format pn or json')
152
+ end
153
+
140
154
  option("--[no-]header") do
141
155
  summary _("Whether or not to show a file name header between files.")
142
156
  end
@@ -353,7 +367,6 @@ Puppet::Face.define(:epp, '0.0.1') do
353
367
 
354
368
  def dump_parse(source, filename, options, show_filename = true)
355
369
  output = ""
356
- dumper = Puppet::Pops::Model::ModelTreeDumper.new
357
370
  evaluating_parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new
358
371
  begin
359
372
  if options[:validate]
@@ -365,7 +378,19 @@ Puppet::Face.define(:epp, '0.0.1') do
365
378
  if show_filename && options[:header]
366
379
  output << "--- #{filename}\n"
367
380
  end
368
- output << dumper.dump(parse_result) << "\n"
381
+ fmt = options[:format]
382
+ if fmt.nil? || fmt == 'old'
383
+ output << Puppet::Pops::Model::ModelTreeDumper.new.dump(parse_result) << "\n"
384
+ else
385
+ require 'puppet/pops/pn'
386
+ pn = Puppet::Pops::Model::PNTransformer.transform(parse_result)
387
+ case fmt
388
+ when 'json'
389
+ options[:pretty] ? JSON.pretty_unparse(pn.to_data) : JSON.dump(pn.to_data)
390
+ else
391
+ pn.format(options[:pretty] ? Puppet::Pops::PN::Indent.new(' ') : nil, output)
392
+ end
393
+ end
369
394
  rescue Puppet::ParseError => detail
370
395
  if show_filename
371
396
  Puppet.err("--- #{filename}")
@@ -35,4 +35,53 @@ Puppet::Indirector::Face.define(:facts, '0.0.1') do
35
35
 
36
36
  deactivate_action(:destroy)
37
37
  deactivate_action(:search)
38
+
39
+ action(:upload) do
40
+ summary _("Upload local facts to the puppet master.")
41
+ description <<-'EOT'
42
+ Reads facts from the local system using the `facter` terminus, then
43
+ saves the returned facts using the rest terminus.
44
+ EOT
45
+ returns "Nothing."
46
+ notes <<-'EOT'
47
+ This action requires that the puppet master's `auth.conf` file
48
+ allow `PUT` or `save` access to the `/puppet/v3/facts` API endpoint.
49
+
50
+ For details on configuring Puppet Server's `auth.conf`, see:
51
+
52
+ <https://puppet.com/docs/puppetserver/latest/config_file_auth.html>
53
+
54
+ For legacy Rack-based Puppet Masters, see:
55
+
56
+ <https://puppet.com/docs/puppet/latest/config_file_auth.html>
57
+ EOT
58
+ examples <<-'EOT'
59
+ Upload facts:
60
+
61
+ $ puppet facts upload
62
+ EOT
63
+
64
+ render_as :json
65
+
66
+ when_invoked do |options|
67
+ # Use `agent` sections settings for certificates, Puppet Server URL,
68
+ # etc. instead of `user` section settings.
69
+ Puppet.settings.preferred_run_mode = :agent
70
+ Puppet::Node::Facts.indirection.terminus_class = :facter
71
+
72
+ facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value])
73
+ unless Puppet[:node_name_fact].empty?
74
+ Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
75
+ facts.name = Puppet[:node_name_value]
76
+ end
77
+
78
+ Puppet::Node::Facts.indirection.terminus_class = :rest
79
+ server = Puppet::Node::Facts::Rest.server
80
+ Puppet.notice(_("Uploading facts for '%{node}' to: '%{server}'") % {
81
+ node: Puppet[:node_name_value],
82
+ server: server})
83
+
84
+ Puppet::Node::Facts.indirection.save(facts)
85
+ end
86
+ end
38
87
  end
@@ -26,47 +26,33 @@ Puppet::Face.define(:help, '0.0.1') do
26
26
 
27
27
  default
28
28
  when_invoked do |*args|
29
- # Check our invocation, because we want varargs and can't do defaults
30
- # yet. REVISIT: when we do option defaults, and positional options, we
31
- # should rewrite this to use those. --daniel 2011-04-04
32
29
  options = args.pop
33
- if options.nil? or args.length > 2 then
34
- if args.select { |x| x == 'help' }.length > 2 then
35
- c = "\n %'(),-./=ADEFHILORSTUXY\\_`gnv|".split('')
36
- i = <<-'EOT'.gsub(/\s*/, '').to_i(36)
37
- 3he6737w1aghshs6nwrivl8mz5mu9nywg9tbtlt081uv6fq5kvxse1td3tj1wvccmte806nb
38
- cy6de2ogw0fqjymbfwi6a304vd56vlq71atwmqsvz3gpu0hj42200otlycweufh0hylu79t3
39
- gmrijm6pgn26ic575qkexyuoncbujv0vcscgzh5us2swklsp5cqnuanlrbnget7rt3956kam
40
- j8adhdrzqqt9bor0cv2fqgkloref0ygk3dekiwfj1zxrt13moyhn217yy6w4shwyywik7w0l
41
- xtuevmh0m7xp6eoswin70khm5nrggkui6z8vdjnrgdqeojq40fya5qexk97g4d8qgw0hvokr
42
- pli1biaz503grqf2ycy0ppkhz1hwhl6ifbpet7xd6jjepq4oe0ofl575lxdzjeg25217zyl4
43
- nokn6tj5pq7gcdsjre75rqylydh7iia7s3yrko4f5ud9v8hdtqhu60stcitirvfj6zphppmx
44
- 7wfm7i9641d00bhs44n6vh6qvx39pg3urifgr6ihx3e0j1ychzypunyou7iplevitkyg6gbg
45
- wm08oy1rvogcjakkqc1f7y1awdfvlb4ego8wrtgu9vzw4vmj59utwifn2ejcs569dh1oaavi
46
- sc581n7jjg1dugzdu094fdobtx6rsvk3sfctvqnr36xctold
47
- EOT
48
- 353.times{i,x=i.divmod(1184);a,b=x.divmod(37);print(c[a]*b)}
49
- end
50
- raise ArgumentError, _("Puppet help only takes two (optional) arguments: a subcommand and an action")
30
+
31
+ if default_case?(args) || help_for_help?(args)
32
+ return erb('global.erb').result(binding)
33
+ end
34
+
35
+ if args.length > 2
36
+ #TRANSLATORS 'puppet help' is a command line and should not be translated
37
+ raise ArgumentError, _("The 'puppet help' command takes two (optional) arguments: a subcommand and an action")
51
38
  end
52
39
 
53
40
  version = :current
54
- if options.has_key? :version then
55
- if options[:version].to_s !~ /^current$/i then
41
+ if options.has_key? :version
42
+ if options[:version].to_s !~ /^current$/i
56
43
  version = options[:version]
57
44
  else
58
- if args.length == 0 then
59
- raise ArgumentError, _("Version only makes sense when a Faces subcommand is given")
45
+ if args.length == 0
46
+ #TRANSLATORS '--version' is a command line option and should not be translated
47
+ raise ArgumentError, _("Supplying a '--version' only makes sense when a Faces subcommand is given")
60
48
  end
61
49
  end
62
50
  end
63
51
 
64
- return erb('global.erb').result(binding) if args.empty?
65
-
66
52
  facename, actionname = args
67
- if legacy_applications.include? facename then
68
- if actionname then
69
- raise ArgumentError, _("Legacy subcommands don't take actions")
53
+ if legacy_applications.include? facename
54
+ if actionname
55
+ raise ArgumentError, _("The legacy subcommand '%{sub_command}' does not support supplying an action") % { sub_command: facename }
70
56
  end
71
57
  return render_application_help(facename)
72
58
  else
@@ -75,6 +61,14 @@ Puppet::Face.define(:help, '0.0.1') do
75
61
  end
76
62
  end
77
63
 
64
+ def default_case?(args)
65
+ args.empty?
66
+ end
67
+
68
+ def help_for_help?(args)
69
+ args.length == 1 && args.first == 'help'
70
+ end
71
+
78
72
  def render_application_help(applicationname)
79
73
  return Puppet::Application[applicationname].help
80
74
  rescue StandardError, LoadError => detail
@@ -102,7 +96,7 @@ Puppet::Face.define(:help, '0.0.1') do
102
96
  face = Puppet::Face[facename.to_sym, version]
103
97
  if actionname
104
98
  action = face.get_action(actionname.to_sym)
105
- if not action
99
+ if ! action
106
100
  fail ArgumentError, _("Unable to load action %{actionname} from %{face}") % { actionname: actionname, face: face }
107
101
  end
108
102
  end
@@ -145,10 +139,12 @@ Puppet::Face.define(:help, '0.0.1') do
145
139
  begin
146
140
  face = Puppet::Face[appname, :current]
147
141
  # Add deprecation message to summary if the face is deprecated
148
- summary = face.deprecated? ? face.summary + _(" (Deprecated)") : face.summary
142
+ summary = face.deprecated? ? face.summary + ' ' + _("(Deprecated)") : face.summary
149
143
  result << [appname, summary]
150
144
  rescue StandardError, LoadError
151
- result << [ "! #{appname}", _("! Subcommand unavailable due to error. Check error logs.") ]
145
+ error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
146
+ error_message += ' ' + _("Check error logs.")
147
+ result << [ error_message ]
152
148
  end
153
149
  else
154
150
  begin
@@ -158,7 +154,9 @@ Puppet::Face.define(:help, '0.0.1') do
158
154
  end
159
155
  result << [appname, summary]
160
156
  rescue StandardError, LoadError
161
- result << ["! #{appname}", _("! Subcommand unavailable due to error. Check error logs.")]
157
+ error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
158
+ error_message += ' ' + _("Check error logs.")
159
+ result << [ error_message ]
162
160
  end
163
161
  end
164
162
  end
@@ -171,7 +169,7 @@ Puppet::Face.define(:help, '0.0.1') do
171
169
  # formatted. If we can't match the pattern we expect we return the empty
172
170
  # string to ensure we don't blow up in the summary. --daniel 2011-04-11
173
171
  while line = help.shift do
174
- if md = /^puppet-#{appname}\([^\)]+\) -- (.*)$/.match(line) then
172
+ if md = /^puppet-#{appname}\([^\)]+\) -- (.*)$/.match(line)
175
173
  return md[1]
176
174
  end
177
175
  end