bolt 0.20.3 → 0.20.5

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 (256) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +3 -3
  3. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +33 -0
  4. data/lib/bolt/inventory.rb +19 -1
  5. data/lib/bolt/target.rb +15 -0
  6. data/lib/bolt/transport/local.rb +6 -1
  7. data/lib/bolt/transport/orch.rb +2 -0
  8. data/lib/bolt/transport/ssh.rb +7 -2
  9. data/lib/bolt/transport/winrm.rb +6 -1
  10. data/lib/bolt/version.rb +1 -1
  11. data/modules/facts/plans/retrieve.pp +2 -26
  12. data/modules/facts/tasks/init.json +9 -0
  13. data/vendored/puppet/lib/hiera/puppet_function.rb +1 -1
  14. data/vendored/puppet/lib/hiera/scope.rb +24 -2
  15. data/vendored/puppet/lib/puppet.rb +4 -13
  16. data/vendored/puppet/lib/puppet/application.rb +2 -2
  17. data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
  18. data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
  19. data/vendored/puppet/lib/puppet/application/cert.rb +1 -1
  20. data/vendored/puppet/lib/puppet/application/device.rb +8 -8
  21. data/vendored/puppet/lib/puppet/application/face_base.rb +1 -1
  22. data/vendored/puppet/lib/puppet/application/lookup.rb +2 -2
  23. data/vendored/puppet/lib/puppet/application/resource.rb +2 -2
  24. data/vendored/puppet/lib/puppet/application/script.rb +1 -1
  25. data/vendored/puppet/lib/puppet/configurer.rb +47 -24
  26. data/vendored/puppet/lib/puppet/confine.rb +4 -1
  27. data/vendored/puppet/lib/puppet/context.rb +1 -1
  28. data/vendored/puppet/lib/puppet/defaults.rb +32 -44
  29. data/vendored/puppet/lib/puppet/error.rb +14 -7
  30. data/vendored/puppet/lib/puppet/external/dot.rb +23 -17
  31. data/vendored/puppet/lib/puppet/face/config.rb +58 -3
  32. data/vendored/puppet/lib/puppet/face/epp.rb +1 -1
  33. data/vendored/puppet/lib/puppet/face/module/build.rb +3 -3
  34. data/vendored/puppet/lib/puppet/face/module/install.rb +0 -4
  35. data/vendored/puppet/lib/puppet/face/module/list.rb +0 -5
  36. data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
  37. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -4
  38. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -4
  39. data/vendored/puppet/lib/puppet/face/status.rb +2 -2
  40. data/vendored/puppet/lib/puppet/file_serving/base.rb +5 -5
  41. data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -1
  42. data/vendored/puppet/lib/puppet/forge.rb +7 -8
  43. data/vendored/puppet/lib/puppet/forge/errors.rb +3 -3
  44. data/vendored/puppet/lib/puppet/functions/abs.rb +61 -0
  45. data/vendored/puppet/lib/puppet/functions/all.rb +2 -2
  46. data/vendored/puppet/lib/puppet/functions/any.rb +2 -2
  47. data/vendored/puppet/lib/puppet/functions/assert_type.rb +3 -3
  48. data/vendored/puppet/lib/puppet/functions/break.rb +3 -7
  49. data/vendored/puppet/lib/puppet/functions/camelcase.rb +62 -0
  50. data/vendored/puppet/lib/puppet/functions/capitalize.rb +61 -0
  51. data/vendored/puppet/lib/puppet/functions/ceiling.rb +37 -0
  52. data/vendored/puppet/lib/puppet/functions/chomp.rb +57 -0
  53. data/vendored/puppet/lib/puppet/functions/chop.rb +67 -0
  54. data/vendored/puppet/lib/puppet/functions/compare.rb +125 -0
  55. data/vendored/puppet/lib/puppet/functions/convert_to.rb +3 -2
  56. data/vendored/puppet/lib/puppet/functions/dig.rb +21 -1
  57. data/vendored/puppet/lib/puppet/functions/downcase.rb +89 -0
  58. data/vendored/puppet/lib/puppet/functions/each.rb +2 -2
  59. data/vendored/puppet/lib/puppet/functions/empty.rb +1 -3
  60. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  61. data/vendored/puppet/lib/puppet/functions/filter.rb +2 -2
  62. data/vendored/puppet/lib/puppet/functions/floor.rb +37 -0
  63. data/vendored/puppet/lib/puppet/functions/get.rb +150 -0
  64. data/vendored/puppet/lib/puppet/functions/getvar.rb +87 -0
  65. data/vendored/puppet/lib/puppet/functions/hiera.rb +5 -5
  66. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +5 -5
  67. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
  68. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +7 -7
  69. data/vendored/puppet/lib/puppet/functions/hocon_data.rb +1 -1
  70. data/vendored/puppet/lib/puppet/functions/json_data.rb +3 -3
  71. data/vendored/puppet/lib/puppet/functions/lest.rb +1 -1
  72. data/vendored/puppet/lib/puppet/functions/lookup.rb +3 -2
  73. data/vendored/puppet/lib/puppet/functions/lstrip.rb +58 -0
  74. data/vendored/puppet/lib/puppet/functions/map.rb +1 -1
  75. data/vendored/puppet/lib/puppet/functions/match.rb +11 -0
  76. data/vendored/puppet/lib/puppet/functions/max.rb +183 -0
  77. data/vendored/puppet/lib/puppet/functions/min.rb +182 -0
  78. data/vendored/puppet/lib/puppet/functions/next.rb +1 -8
  79. data/vendored/puppet/lib/puppet/functions/reduce.rb +1 -1
  80. data/vendored/puppet/lib/puppet/functions/return.rb +1 -8
  81. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +1 -1
  82. data/vendored/puppet/lib/puppet/functions/round.rb +24 -0
  83. data/vendored/puppet/lib/puppet/functions/rstrip.rb +58 -0
  84. data/vendored/puppet/lib/puppet/functions/size.rb +15 -0
  85. data/vendored/puppet/lib/puppet/functions/sort.rb +74 -0
  86. data/vendored/puppet/lib/puppet/functions/step.rb +1 -1
  87. data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -7
  88. data/vendored/puppet/lib/puppet/functions/strip.rb +58 -0
  89. data/vendored/puppet/lib/puppet/functions/then.rb +1 -1
  90. data/vendored/puppet/lib/puppet/functions/tree_each.rb +7 -7
  91. data/vendored/puppet/lib/puppet/functions/upcase.rb +89 -0
  92. data/vendored/puppet/lib/puppet/functions/with.rb +4 -4
  93. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -2
  94. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
  95. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
  96. data/vendored/puppet/lib/puppet/indirector/indirection.rb +8 -12
  97. data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -1
  98. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +1 -1
  99. data/vendored/puppet/lib/puppet/indirector/request.rb +11 -11
  100. data/vendored/puppet/lib/puppet/indirector/rest.rb +11 -11
  101. data/vendored/puppet/lib/puppet/interface/action.rb +2 -5
  102. data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -2
  103. data/vendored/puppet/lib/puppet/module.rb +7 -33
  104. data/vendored/puppet/lib/puppet/module/task.rb +0 -1
  105. data/vendored/puppet/lib/puppet/module_tool.rb +2 -5
  106. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +5 -5
  107. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +2 -2
  108. data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +3 -3
  109. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +6 -7
  110. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +1 -2
  111. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +2 -2
  112. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +5 -6
  113. data/vendored/puppet/lib/puppet/module_tool/dependency.rb +1 -1
  114. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +2 -2
  115. data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +3 -3
  116. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +3 -4
  117. data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +2 -2
  118. data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -13
  119. data/vendored/puppet/lib/puppet/network/format_support.rb +1 -1
  120. data/vendored/puppet/lib/puppet/network/formats.rb +5 -7
  121. data/vendored/puppet/lib/puppet/network/http.rb +0 -2
  122. data/vendored/puppet/lib/puppet/network/http/api.rb +1 -10
  123. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
  124. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
  125. data/vendored/puppet/lib/puppet/network/http/compression.rb +1 -1
  126. data/vendored/puppet/lib/puppet/network/http/connection.rb +11 -3
  127. data/vendored/puppet/lib/puppet/network/http/error.rb +3 -3
  128. data/vendored/puppet/lib/puppet/network/http/factory.rb +3 -0
  129. data/vendored/puppet/lib/puppet/network/http/handler.rb +59 -27
  130. data/vendored/puppet/lib/puppet/network/resolver.rb +140 -67
  131. data/vendored/puppet/lib/puppet/node/environment.rb +2 -19
  132. data/vendored/puppet/lib/puppet/parameter.rb +12 -7
  133. data/vendored/puppet/lib/puppet/parser/ast.rb +4 -8
  134. data/vendored/puppet/lib/puppet/parser/ast/branch.rb +3 -3
  135. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +5 -0
  136. data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +18 -0
  137. data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -4
  138. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
  139. data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
  140. data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +3 -3
  141. data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +1 -7
  142. data/vendored/puppet/lib/puppet/parser/functions/each.rb +2 -2
  143. data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
  144. data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +4 -4
  145. data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +5 -5
  146. data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +6 -6
  147. data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +10 -11
  148. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -1
  149. data/vendored/puppet/lib/puppet/parser/functions/lest.rb +1 -1
  150. data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +1 -1
  151. data/vendored/puppet/lib/puppet/parser/functions/map.rb +1 -1
  152. data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +1 -1
  153. data/vendored/puppet/lib/puppet/parser/functions/return.rb +22 -1
  154. data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +1 -1
  155. data/vendored/puppet/lib/puppet/parser/functions/step.rb +1 -1
  156. data/vendored/puppet/lib/puppet/parser/functions/then.rb +1 -1
  157. data/vendored/puppet/lib/puppet/parser/functions/with.rb +4 -4
  158. data/vendored/puppet/lib/puppet/parser/resource.rb +0 -1
  159. data/vendored/puppet/lib/puppet/parser/resource/param.rb +12 -5
  160. data/vendored/puppet/lib/puppet/parser/scope.rb +5 -7
  161. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -1
  162. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
  163. data/vendored/puppet/lib/puppet/pops/issues.rb +4 -0
  164. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
  165. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +17 -12
  166. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +73 -45
  167. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
  168. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  169. data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +1 -1
  170. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +6 -2
  171. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  172. data/vendored/puppet/lib/puppet/pops/pcore.rb +7 -7
  173. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +15 -1
  174. data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -2
  175. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -2
  176. data/vendored/puppet/lib/puppet/pops/serialization/json.rb +7 -7
  177. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
  178. data/vendored/puppet/lib/puppet/pops/types/types.rb +8 -4
  179. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +73 -0
  180. data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
  181. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +7 -0
  182. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
  183. data/vendored/puppet/lib/puppet/provider/user/aix.rb +2 -2
  184. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +21 -9
  185. data/vendored/puppet/lib/puppet/reference/providers.rb +1 -1
  186. data/vendored/puppet/lib/puppet/reference/report.rb +1 -1
  187. data/vendored/puppet/lib/puppet/resource.rb +1 -1
  188. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +4 -4
  189. data/vendored/puppet/lib/puppet/resource/catalog.rb +6 -3
  190. data/vendored/puppet/lib/puppet/resource/type.rb +6 -2
  191. data/vendored/puppet/lib/puppet/rest/client.rb +79 -0
  192. data/vendored/puppet/lib/puppet/rest/errors.rb +14 -0
  193. data/vendored/puppet/lib/puppet/rest/response.rb +29 -0
  194. data/vendored/puppet/lib/puppet/rest/route.rb +102 -0
  195. data/vendored/puppet/lib/puppet/rest/routes.rb +31 -0
  196. data/vendored/puppet/lib/puppet/settings.rb +9 -5
  197. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
  198. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +10 -1
  199. data/vendored/puppet/lib/puppet/ssl.rb +0 -1
  200. data/vendored/puppet/lib/puppet/ssl/certificate.rb +6 -2
  201. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +3 -3
  202. data/vendored/puppet/lib/puppet/ssl/host.rb +258 -19
  203. data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +33 -19
  204. data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +1 -1
  205. data/vendored/puppet/lib/puppet/transaction/event.rb +34 -7
  206. data/vendored/puppet/lib/puppet/transaction/report.rb +17 -14
  207. data/vendored/puppet/lib/puppet/type.rb +20 -12
  208. data/vendored/puppet/lib/puppet/type/file.rb +1 -1
  209. data/vendored/puppet/lib/puppet/type/file/content.rb +15 -2
  210. data/vendored/puppet/lib/puppet/type/file/ensure.rb +1 -1
  211. data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
  212. data/vendored/puppet/lib/puppet/type/stage.rb +1 -1
  213. data/vendored/puppet/lib/puppet/type/tidy.rb +5 -1
  214. data/vendored/puppet/lib/puppet/type/user.rb +35 -18
  215. data/vendored/puppet/lib/puppet/type/yumrepo.rb +8 -17
  216. data/vendored/puppet/lib/puppet/util.rb +0 -1
  217. data/vendored/puppet/lib/puppet/util/autoload.rb +1 -6
  218. data/vendored/puppet/lib/puppet/util/checksums.rb +0 -2
  219. data/vendored/puppet/lib/puppet/util/classgen.rb +0 -6
  220. data/vendored/puppet/lib/puppet/util/fileparsing.rb +27 -5
  221. data/vendored/puppet/lib/puppet/util/instance_loader.rb +3 -3
  222. data/vendored/puppet/lib/puppet/util/json.rb +77 -0
  223. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +3 -3
  224. data/vendored/puppet/lib/puppet/util/ldap/connection.rb +7 -7
  225. data/vendored/puppet/lib/puppet/util/log/destinations.rb +2 -2
  226. data/vendored/puppet/lib/puppet/util/logging.rb +1 -1
  227. data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
  228. data/vendored/puppet/lib/puppet/util/provider_features.rb +2 -5
  229. data/vendored/puppet/lib/puppet/util/reference.rb +5 -4
  230. data/vendored/puppet/lib/puppet/util/tagging.rb +16 -3
  231. data/vendored/puppet/lib/puppet/version.rb +1 -1
  232. metadata +44 -26
  233. data/vendored/puppet/lib/puppet/application/master.rb +0 -317
  234. data/vendored/puppet/lib/puppet/feature/rack.rb +0 -19
  235. data/vendored/puppet/lib/puppet/network/http/api/ca.rb +0 -2
  236. data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +0 -11
  237. data/vendored/puppet/lib/puppet/network/http/rack.rb +0 -33
  238. data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +0 -162
  239. data/vendored/puppet/lib/puppet/network/http/webrick.rb +0 -124
  240. data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +0 -114
  241. data/vendored/puppet/lib/puppet/network/server.rb +0 -39
  242. data/vendored/puppet/lib/puppet/ssl/configuration.rb +0 -61
  243. data/vendored/puppet/lib/puppet/util/methodhelper.rb +0 -32
  244. data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +0 -1
  245. data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
  246. data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
  247. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -11
  248. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
  249. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
  250. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
  251. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
  252. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
  253. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
  254. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
  255. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
  256. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +0 -758
@@ -1,19 +0,0 @@
1
- require 'puppet/util/feature'
2
-
3
- # See if we have rack available, an HTTP Application Stack
4
- # Explicitly depend on rack library version >= 1.0.0
5
- Puppet.features.add(:rack) do
6
- require 'rack'
7
-
8
- if ! (defined?(::Rack) and defined?(::Rack.release))
9
- false
10
- else
11
- major_version = ::Rack.release.split('.')[0].to_i
12
- if major_version >= 1
13
- true
14
- else
15
- false
16
- end
17
- end
18
- end
19
-
@@ -1,2 +0,0 @@
1
- module Puppet::Network::HTTP::API::CA
2
- end
@@ -1,11 +0,0 @@
1
- require 'puppet/network/http/api/indirected_routes'
2
- class Puppet::Network::HTTP::API::CA::V1
3
-
4
- INDIRECTED = Puppet::Network::HTTP::Route.
5
- path(/.*/).
6
- any(Puppet::Network::HTTP::API::IndirectedRoutes.new)
7
-
8
- def self.routes
9
- Puppet::Network::HTTP::Route.path(%r{v1}).any.chain(INDIRECTED)
10
- end
11
- end
@@ -1,33 +0,0 @@
1
- require 'rack'
2
- require 'rack/request'
3
- require 'rack/response'
4
-
5
- require 'puppet/network/http'
6
- require 'puppet/network/http/rack/rest'
7
-
8
- # An rack application, for running the Puppet HTTP Server.
9
- class Puppet::Network::HTTP::Rack
10
- # The real rack application (which needs to respond to call).
11
- # The work we need to do, roughly is:
12
- # * Read request (from env) and prepare a response
13
- # * Route the request to the correct handler
14
- # * Return the response (in rack-format) to our caller.
15
- def call(env)
16
- request = Rack::Request.new(env)
17
- response = Rack::Response.new
18
- Puppet.debug 'Handling request: %s %s' % [request.request_method, request.fullpath]
19
-
20
- begin
21
- Puppet::Network::HTTP::RackREST.new.process(request, response)
22
- rescue => detail
23
- # Send a Status 500 Error on unhandled exceptions.
24
- response.status = 500
25
- response['Content-Type'] = 'text/plain'
26
- response.write _("Internal Server Error: \"%{message}\"") % { message: detail.message }
27
- # log what happened
28
- Puppet.log_exception(detail, _("Puppet Server (Rack): Internal Server Error: Unhandled Exception: \"%{message}\"") % { message: detail.message })
29
- end
30
- response.finish
31
- end
32
- end
33
-
@@ -1,162 +0,0 @@
1
- require 'openssl'
2
- require 'cgi'
3
- require 'puppet/network/http/handler'
4
- require 'puppet/util/ssl'
5
- require 'uri'
6
-
7
- class Puppet::Network::HTTP::RackREST
8
- include Puppet::Network::HTTP::Handler
9
-
10
- ContentType = 'Content-Type'.freeze
11
-
12
- CHUNK_SIZE = 8192
13
-
14
- class RackFile
15
- def initialize(file)
16
- @file = file
17
- end
18
-
19
- def each
20
- while chunk = @file.read(CHUNK_SIZE)
21
- yield chunk
22
- end
23
- end
24
-
25
- def close
26
- @file.close
27
- end
28
- end
29
-
30
- def initialize(args={})
31
- super()
32
- register([Puppet::Network::HTTP::API.master_routes,
33
- Puppet::Network::HTTP::API.ca_routes,
34
- Puppet::Network::HTTP::API.not_found_upgrade])
35
- end
36
-
37
- def set_content_type(response, format)
38
- response[ContentType] = format
39
- end
40
-
41
- # produce the body of the response
42
- def set_response(response, result, status = 200)
43
- response.status = status
44
- unless result.is_a?(File)
45
- response.write result
46
- else
47
- response["Content-Length"] = result.stat.size.to_s
48
- response.body = RackFile.new(result)
49
- end
50
- end
51
-
52
- # Retrieve all headers from the http request, as a map.
53
- def headers(request)
54
- headers = request.env.select {|k,v| k.start_with? 'HTTP_'}.inject({}) do |m, (k,v)|
55
- m[k.sub(/^HTTP_/, '').gsub('_','-').downcase] = v
56
- m
57
- end
58
- headers['content-type'] = request.content_type
59
- headers
60
- end
61
-
62
- # Return which HTTP verb was used in this request.
63
- def http_method(request)
64
- request.request_method
65
- end
66
-
67
- # Return the query params for this request.
68
- def params(request)
69
- if request.post?
70
- params = request.params
71
- else
72
- # rack doesn't support multi-valued query parameters,
73
- # e.g. ignore, so parse them ourselves
74
- params = CGI.parse(request.query_string)
75
- convert_singular_arrays_to_value(params)
76
- end
77
- result = decode_params(params)
78
- result.merge(extract_client_info(request))
79
- end
80
-
81
- # what path was requested? (this is, without any query parameters)
82
- def path(request)
83
- # The value that Passenger provides for 'path' is escaped
84
- # (URL percent-encoded), see
85
- # https://github.com/phusion/passenger/blob/release-5.0.26/src/apache2_module/Hooks.cpp#L885
86
- # for the implementation as hooked up to an Apache web server. Code
87
- # in the indirector / HTTP layer which consumes this path, however, assumes
88
- # that it has already been unescaped, so it is unescaped here.
89
- if request.path
90
- # don't use CGI.unescape which mangles space handling
91
- URI.unescape(request.path.encode(Encoding::UTF_8))
92
- end
93
- end
94
-
95
- # return the request body
96
- def body(request)
97
- request.body.read
98
- end
99
-
100
- def client_cert(request)
101
- # This environment variable is set by mod_ssl, note that it
102
- # requires the `+ExportCertData` option in the `SSLOptions` directive
103
- cert = request.env['SSL_CLIENT_CERT']
104
- # NOTE: The SSL_CLIENT_CERT environment variable will be the empty string
105
- # when Puppet agent nodes have not yet obtained a signed certificate.
106
- if cert.nil? || cert.empty?
107
- # When running with unicorn, the SSL_CLIENT_CERT variable is not available
108
- # in the environment, therefore we have to pass a header: 'X-SSL-Client-Cert'
109
- cert = request.env['HTTP_X_SSL_CLIENT_CERT']
110
- if cert.nil? || cert.empty?
111
- nil
112
- else
113
- # in contrast to the environment variable, the client cert is passed in
114
- # as single string, therefore restore the certificate to a valid pem
115
- # encoded certificate
116
- cert.gsub!(/ /, "\n")
117
- cert.gsub!(/BEGIN\nCERT/, "BEGIN CERT")
118
- cert.gsub!(/END\nCERT/, "END CERT")
119
- cert = Puppet::SSL::Certificate.from_instance(OpenSSL::X509::Certificate.new(cert))
120
- cert
121
- end
122
- else
123
- Puppet::SSL::Certificate.from_instance(OpenSSL::X509::Certificate.new(cert))
124
- end
125
- end
126
-
127
- # Passenger freaks out if we finish handling the request without reading any
128
- # part of the body, so make sure we have.
129
- def cleanup(request)
130
- request.body.read(1)
131
- nil
132
- end
133
-
134
- def extract_client_info(request)
135
- result = {}
136
- result[:ip] = request.ip
137
-
138
- # if we find SSL info in the headers, use them to get a hostname from the CN.
139
- # try this with :ssl_client_header, which defaults should work for
140
- # Apache with StdEnvVars.
141
- subj_str = request.env[Puppet[:ssl_client_header]]
142
- subject = Puppet::Util::SSL.subject_from_dn(subj_str || "")
143
-
144
- if cn = Puppet::Util::SSL.cn_from_subject(subject)
145
- result[:node] = cn
146
- result[:authenticated] = (request.env[Puppet[:ssl_client_verify_header]] == 'SUCCESS')
147
- else
148
- result[:node] = resolve_node(result)
149
- result[:authenticated] = false
150
- end
151
-
152
- result
153
- end
154
-
155
- def convert_singular_arrays_to_value(hash)
156
- hash.each do |key, value|
157
- if value.size == 1
158
- hash[key] = value.first
159
- end
160
- end
161
- end
162
- end
@@ -1,124 +0,0 @@
1
- require 'webrick'
2
- require 'webrick/https'
3
- require 'puppet/network/http/webrick/rest'
4
- require 'thread'
5
-
6
- require 'puppet/ssl/certificate'
7
- require 'puppet/ssl/certificate_revocation_list'
8
- require 'puppet/ssl/configuration'
9
-
10
- class Puppet::Network::HTTP::WEBrick
11
- CIPHERS = "EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA"
12
-
13
- def initialize
14
- @listening = false
15
- end
16
-
17
- def listen(address, port)
18
- @server = create_server(address, port)
19
-
20
- @server.mount('/', Puppet::Network::HTTP::WEBrickREST)
21
-
22
- raise _("WEBrick server is already listening") if @listening
23
- @listening = true
24
- @thread = Thread.new do
25
- @server.start do |sock|
26
- timeout = 10.0
27
- if ! IO.select([sock],nil,nil,timeout)
28
- raise _("Client did not send data within %{timeout} seconds of connecting") % { timeout: ("%.1f") % timeout }
29
- end
30
- sock.accept
31
- @server.run(sock)
32
- end
33
- end
34
- sleep 0.1 until @server.status == :Running
35
- end
36
-
37
- def unlisten
38
- raise _("WEBrick server is not listening") unless @listening
39
- @server.shutdown
40
- wait_for_shutdown
41
- @server = nil
42
- @listening = false
43
- end
44
-
45
- def listening?
46
- @listening
47
- end
48
-
49
- def wait_for_shutdown
50
- @thread.join
51
- end
52
-
53
- # @api private
54
- def create_server(address, port)
55
- address = nil if address == '*'
56
- arguments = {:BindAddress => address, :Port => port, :DoNotReverseLookup => true}
57
- arguments.merge!(setup_logger)
58
- arguments.merge!(setup_ssl)
59
-
60
- BasicSocket.do_not_reverse_lookup = true
61
-
62
- server = WEBrick::HTTPServer.new(arguments)
63
- server.ssl_context.ciphers = CIPHERS
64
- server
65
- end
66
-
67
- # Configure our http log file.
68
- def setup_logger
69
- # Make sure the settings are all ready for us.
70
- Puppet.settings.use(:main, :ssl, :application)
71
-
72
- file = Puppet[:masterhttplog]
73
-
74
- # open the log manually to prevent file descriptor leak
75
- # webrick logged strings may contain UTF-8
76
- file_io = ::File.open(file, "a+:UTF-8")
77
- file_io.sync = true
78
- if defined?(Fcntl::FD_CLOEXEC)
79
- file_io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
80
- end
81
-
82
- args = [file_io]
83
- args << WEBrick::Log::DEBUG if Puppet::Util::Log.level == :debug
84
-
85
- logger = WEBrick::Log.new(*args)
86
- return :Logger => logger, :AccessLog => [
87
- [logger, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
88
- [logger, WEBrick::AccessLog::REFERER_LOG_FORMAT ]
89
- ]
90
- end
91
-
92
- # Add all of the ssl cert information.
93
- def setup_ssl
94
- results = {}
95
-
96
- # Get the cached copy. We know it's been generated, too.
97
- host = Puppet::SSL::Host.localhost
98
-
99
- raise Puppet::Error, _("Could not retrieve certificate for %{host} and not running on a valid certificate authority") % { value0: host.name } unless host.certificate
100
-
101
- results[:SSLPrivateKey] = host.key.content
102
- results[:SSLCertificate] = host.certificate.content
103
- results[:SSLStartImmediately] = false
104
- results[:SSLEnable] = true
105
- results[:SSLOptions] = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
106
-
107
- raise Puppet::Error, _("Could not find CA certificate") unless Puppet::SSL::Certificate.indirection.find(Puppet::SSL::CA_NAME)
108
-
109
- results[:SSLCACertificateFile] = ssl_configuration.ca_auth_file
110
- results[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_PEER
111
-
112
- results[:SSLCertificateStore] = host.ssl_store
113
-
114
- results
115
- end
116
-
117
- private
118
-
119
- def ssl_configuration
120
- @ssl_configuration ||= Puppet::SSL::Configuration.new(
121
- Puppet[:localcacert],
122
- :ca_auth_file => Puppet[:ssl_server_ca_auth])
123
- end
124
- end
@@ -1,114 +0,0 @@
1
- require 'puppet/network/http/handler'
2
- require 'resolv'
3
- require 'webrick'
4
- require 'webrick/httputils'
5
- require 'puppet/util/ssl'
6
-
7
- class Puppet::Network::HTTP::WEBrickREST < WEBrick::HTTPServlet::AbstractServlet
8
-
9
- include Puppet::Network::HTTP::Handler
10
-
11
- def self.mutex
12
- @mutex ||= Mutex.new
13
- end
14
-
15
- def initialize(server)
16
- raise ArgumentError, _("server is required") unless server
17
- register([Puppet::Network::HTTP::API.master_routes,
18
- Puppet::Network::HTTP::API.ca_routes,
19
- Puppet::Network::HTTP::API.not_found_upgrade])
20
- super(server)
21
- end
22
-
23
- # Retrieve the request parameters, including authentication information.
24
- def params(request)
25
- query = request.query || {}
26
- params =
27
- if request.request_method == "PUT"
28
- # webrick doesn't look at the query string for PUT requests, it only
29
- # looks at the body, and then only if the body has a content type that
30
- # looks like url-encoded form data. We need the query string data as well.
31
- WEBrick::HTTPUtils.parse_query(request.query_string).merge(query)
32
- else
33
- query
34
- end
35
-
36
- params = Hash[params.collect do |key, value|
37
- all_values = value.list
38
- [key, all_values.length == 1 ? value : all_values]
39
- end]
40
-
41
- params = decode_params(params)
42
- params.merge(client_information(request))
43
- end
44
-
45
- # WEBrick uses a service method to respond to requests. Simply delegate to
46
- # the handler response method.
47
- def service(request, response)
48
- self.class.mutex.synchronize do
49
- process(request, response)
50
- end
51
- end
52
-
53
- def headers(request)
54
- result = {}
55
- request.each do |k, v|
56
- result[k.downcase] = v
57
- end
58
- result
59
- end
60
-
61
- def http_method(request)
62
- request.request_method
63
- end
64
-
65
- def path(request)
66
- request.path
67
- end
68
-
69
- def body(request)
70
- request.body
71
- end
72
-
73
- def client_cert(request)
74
- if cert = request.client_cert
75
- Puppet::SSL::Certificate.from_instance(cert)
76
- else
77
- nil
78
- end
79
- end
80
-
81
- # Set the specified format as the content type of the response.
82
- def set_content_type(response, format)
83
- response["content-type"] = format
84
- end
85
-
86
- def set_response(response, result, status = 200)
87
- response.status = status
88
- if status >= 200 and status != 304
89
- response.body = result
90
- response["content-length"] = result.stat.size if result.is_a?(File)
91
- end
92
- end
93
-
94
- # Retrieve node/cert/ip information from the request object.
95
- def client_information(request)
96
- result = {}
97
- if peer = request.peeraddr and ip = peer[3]
98
- result[:ip] = ip
99
- end
100
-
101
- # If they have a certificate (which will almost always be true)
102
- # then we get the hostname from the cert, instead of via IP
103
- # info
104
- result[:authenticated] = false
105
- if cert = request.client_cert and cn = Puppet::Util::SSL.cn_from_subject(cert.subject)
106
- result[:node] = cn
107
- result[:authenticated] = true
108
- else
109
- result[:node] = resolve_node(result)
110
- end
111
-
112
- result
113
- end
114
- end