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.
- checksums.yaml +4 -4
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +3 -3
- data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +33 -0
- data/lib/bolt/inventory.rb +19 -1
- data/lib/bolt/target.rb +15 -0
- data/lib/bolt/transport/local.rb +6 -1
- data/lib/bolt/transport/orch.rb +2 -0
- data/lib/bolt/transport/ssh.rb +7 -2
- data/lib/bolt/transport/winrm.rb +6 -1
- data/lib/bolt/version.rb +1 -1
- data/modules/facts/plans/retrieve.pp +2 -26
- data/modules/facts/tasks/init.json +9 -0
- data/vendored/puppet/lib/hiera/puppet_function.rb +1 -1
- data/vendored/puppet/lib/hiera/scope.rb +24 -2
- data/vendored/puppet/lib/puppet.rb +4 -13
- data/vendored/puppet/lib/puppet/application.rb +2 -2
- data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
- data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
- data/vendored/puppet/lib/puppet/application/cert.rb +1 -1
- data/vendored/puppet/lib/puppet/application/device.rb +8 -8
- data/vendored/puppet/lib/puppet/application/face_base.rb +1 -1
- data/vendored/puppet/lib/puppet/application/lookup.rb +2 -2
- data/vendored/puppet/lib/puppet/application/resource.rb +2 -2
- data/vendored/puppet/lib/puppet/application/script.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer.rb +47 -24
- data/vendored/puppet/lib/puppet/confine.rb +4 -1
- data/vendored/puppet/lib/puppet/context.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +32 -44
- data/vendored/puppet/lib/puppet/error.rb +14 -7
- data/vendored/puppet/lib/puppet/external/dot.rb +23 -17
- data/vendored/puppet/lib/puppet/face/config.rb +58 -3
- data/vendored/puppet/lib/puppet/face/epp.rb +1 -1
- data/vendored/puppet/lib/puppet/face/module/build.rb +3 -3
- data/vendored/puppet/lib/puppet/face/module/install.rb +0 -4
- data/vendored/puppet/lib/puppet/face/module/list.rb +0 -5
- data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -4
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -4
- data/vendored/puppet/lib/puppet/face/status.rb +2 -2
- data/vendored/puppet/lib/puppet/file_serving/base.rb +5 -5
- data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -1
- data/vendored/puppet/lib/puppet/forge.rb +7 -8
- data/vendored/puppet/lib/puppet/forge/errors.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/abs.rb +61 -0
- data/vendored/puppet/lib/puppet/functions/all.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/any.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/assert_type.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/break.rb +3 -7
- data/vendored/puppet/lib/puppet/functions/camelcase.rb +62 -0
- data/vendored/puppet/lib/puppet/functions/capitalize.rb +61 -0
- data/vendored/puppet/lib/puppet/functions/ceiling.rb +37 -0
- data/vendored/puppet/lib/puppet/functions/chomp.rb +57 -0
- data/vendored/puppet/lib/puppet/functions/chop.rb +67 -0
- data/vendored/puppet/lib/puppet/functions/compare.rb +125 -0
- data/vendored/puppet/lib/puppet/functions/convert_to.rb +3 -2
- data/vendored/puppet/lib/puppet/functions/dig.rb +21 -1
- data/vendored/puppet/lib/puppet/functions/downcase.rb +89 -0
- data/vendored/puppet/lib/puppet/functions/each.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/empty.rb +1 -3
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/vendored/puppet/lib/puppet/functions/filter.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/floor.rb +37 -0
- data/vendored/puppet/lib/puppet/functions/get.rb +150 -0
- data/vendored/puppet/lib/puppet/functions/getvar.rb +87 -0
- data/vendored/puppet/lib/puppet/functions/hiera.rb +5 -5
- data/vendored/puppet/lib/puppet/functions/hiera_array.rb +5 -5
- data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/hiera_include.rb +7 -7
- data/vendored/puppet/lib/puppet/functions/hocon_data.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/json_data.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/lest.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/lookup.rb +3 -2
- data/vendored/puppet/lib/puppet/functions/lstrip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/map.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/match.rb +11 -0
- data/vendored/puppet/lib/puppet/functions/max.rb +183 -0
- data/vendored/puppet/lib/puppet/functions/min.rb +182 -0
- data/vendored/puppet/lib/puppet/functions/next.rb +1 -8
- data/vendored/puppet/lib/puppet/functions/reduce.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/return.rb +1 -8
- data/vendored/puppet/lib/puppet/functions/reverse_each.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/round.rb +24 -0
- data/vendored/puppet/lib/puppet/functions/rstrip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/size.rb +15 -0
- data/vendored/puppet/lib/puppet/functions/sort.rb +74 -0
- data/vendored/puppet/lib/puppet/functions/step.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -7
- data/vendored/puppet/lib/puppet/functions/strip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/then.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/tree_each.rb +7 -7
- data/vendored/puppet/lib/puppet/functions/upcase.rb +89 -0
- data/vendored/puppet/lib/puppet/functions/with.rb +4 -4
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -2
- data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +8 -12
- data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/request.rb +11 -11
- data/vendored/puppet/lib/puppet/indirector/rest.rb +11 -11
- data/vendored/puppet/lib/puppet/interface/action.rb +2 -5
- data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -2
- data/vendored/puppet/lib/puppet/module.rb +7 -33
- data/vendored/puppet/lib/puppet/module/task.rb +0 -1
- data/vendored/puppet/lib/puppet/module_tool.rb +2 -5
- data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +5 -5
- data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +3 -3
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +6 -7
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +1 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +5 -6
- data/vendored/puppet/lib/puppet/module_tool/dependency.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +3 -3
- data/vendored/puppet/lib/puppet/module_tool/metadata.rb +3 -4
- data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +2 -2
- data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -13
- data/vendored/puppet/lib/puppet/network/format_support.rb +1 -1
- data/vendored/puppet/lib/puppet/network/formats.rb +5 -7
- data/vendored/puppet/lib/puppet/network/http.rb +0 -2
- data/vendored/puppet/lib/puppet/network/http/api.rb +1 -10
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
- data/vendored/puppet/lib/puppet/network/http/compression.rb +1 -1
- data/vendored/puppet/lib/puppet/network/http/connection.rb +11 -3
- data/vendored/puppet/lib/puppet/network/http/error.rb +3 -3
- data/vendored/puppet/lib/puppet/network/http/factory.rb +3 -0
- data/vendored/puppet/lib/puppet/network/http/handler.rb +59 -27
- data/vendored/puppet/lib/puppet/network/resolver.rb +140 -67
- data/vendored/puppet/lib/puppet/node/environment.rb +2 -19
- data/vendored/puppet/lib/puppet/parameter.rb +12 -7
- data/vendored/puppet/lib/puppet/parser/ast.rb +4 -8
- data/vendored/puppet/lib/puppet/parser/ast/branch.rb +3 -3
- data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +18 -0
- data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -4
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
- data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +3 -3
- data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +1 -7
- data/vendored/puppet/lib/puppet/parser/functions/each.rb +2 -2
- data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +4 -4
- data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +5 -5
- data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +6 -6
- data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +10 -11
- data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/lest.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/map.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/return.rb +22 -1
- data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/step.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/then.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/with.rb +4 -4
- data/vendored/puppet/lib/puppet/parser/resource.rb +0 -1
- data/vendored/puppet/lib/puppet/parser/resource/param.rb +12 -5
- data/vendored/puppet/lib/puppet/parser/scope.rb +5 -7
- data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
- data/vendored/puppet/lib/puppet/pops/issues.rb +4 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +17 -12
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +73 -45
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
- data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/pcore.rb +7 -7
- data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +15 -1
- data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/serialization/json.rb +7 -7
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
- data/vendored/puppet/lib/puppet/pops/types/types.rb +8 -4
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +73 -0
- data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +7 -0
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +21 -9
- data/vendored/puppet/lib/puppet/reference/providers.rb +1 -1
- data/vendored/puppet/lib/puppet/reference/report.rb +1 -1
- data/vendored/puppet/lib/puppet/resource.rb +1 -1
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +4 -4
- data/vendored/puppet/lib/puppet/resource/catalog.rb +6 -3
- data/vendored/puppet/lib/puppet/resource/type.rb +6 -2
- data/vendored/puppet/lib/puppet/rest/client.rb +79 -0
- data/vendored/puppet/lib/puppet/rest/errors.rb +14 -0
- data/vendored/puppet/lib/puppet/rest/response.rb +29 -0
- data/vendored/puppet/lib/puppet/rest/route.rb +102 -0
- data/vendored/puppet/lib/puppet/rest/routes.rb +31 -0
- data/vendored/puppet/lib/puppet/settings.rb +9 -5
- data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +10 -1
- data/vendored/puppet/lib/puppet/ssl.rb +0 -1
- data/vendored/puppet/lib/puppet/ssl/certificate.rb +6 -2
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +3 -3
- data/vendored/puppet/lib/puppet/ssl/host.rb +258 -19
- data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +33 -19
- data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +1 -1
- data/vendored/puppet/lib/puppet/transaction/event.rb +34 -7
- data/vendored/puppet/lib/puppet/transaction/report.rb +17 -14
- data/vendored/puppet/lib/puppet/type.rb +20 -12
- data/vendored/puppet/lib/puppet/type/file.rb +1 -1
- data/vendored/puppet/lib/puppet/type/file/content.rb +15 -2
- data/vendored/puppet/lib/puppet/type/file/ensure.rb +1 -1
- data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
- data/vendored/puppet/lib/puppet/type/stage.rb +1 -1
- data/vendored/puppet/lib/puppet/type/tidy.rb +5 -1
- data/vendored/puppet/lib/puppet/type/user.rb +35 -18
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +8 -17
- data/vendored/puppet/lib/puppet/util.rb +0 -1
- data/vendored/puppet/lib/puppet/util/autoload.rb +1 -6
- data/vendored/puppet/lib/puppet/util/checksums.rb +0 -2
- data/vendored/puppet/lib/puppet/util/classgen.rb +0 -6
- data/vendored/puppet/lib/puppet/util/fileparsing.rb +27 -5
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +3 -3
- data/vendored/puppet/lib/puppet/util/json.rb +77 -0
- data/vendored/puppet/lib/puppet/util/json_lockfile.rb +3 -3
- data/vendored/puppet/lib/puppet/util/ldap/connection.rb +7 -7
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +2 -2
- data/vendored/puppet/lib/puppet/util/logging.rb +1 -1
- data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
- data/vendored/puppet/lib/puppet/util/provider_features.rb +2 -5
- data/vendored/puppet/lib/puppet/util/reference.rb +5 -4
- data/vendored/puppet/lib/puppet/util/tagging.rb +16 -3
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- metadata +44 -26
- data/vendored/puppet/lib/puppet/application/master.rb +0 -317
- data/vendored/puppet/lib/puppet/feature/rack.rb +0 -19
- data/vendored/puppet/lib/puppet/network/http/api/ca.rb +0 -2
- data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +0 -11
- data/vendored/puppet/lib/puppet/network/http/rack.rb +0 -33
- data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +0 -162
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +0 -124
- data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +0 -114
- data/vendored/puppet/lib/puppet/network/server.rb +0 -39
- data/vendored/puppet/lib/puppet/ssl/configuration.rb +0 -61
- data/vendored/puppet/lib/puppet/util/methodhelper.rb +0 -32
- data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +0 -1
- data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
- data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -11
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
- 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,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
|