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,5 +1,5 @@
|
|
1
1
|
require 'puppet/network/format_handler'
|
2
|
-
require 'json'
|
2
|
+
require 'puppet/util/json'
|
3
3
|
|
4
4
|
Puppet::Network::FormatHandler.create_serialized_formats(:msgpack, :weight => 20, :mime => "application/x-msgpack", :required_methods => [:render_method, :intern_method], :intern_method => :from_data_hash) do
|
5
5
|
|
@@ -101,19 +101,17 @@ end
|
|
101
101
|
|
102
102
|
Puppet::Network::FormatHandler.create_serialized_formats(:json, :mime => 'application/json', :charset => Encoding::UTF_8, :weight => 15, :required_methods => [:render_method, :intern_method], :intern_method => :from_data_hash) do
|
103
103
|
def intern(klass, text)
|
104
|
-
data_to_instance(klass,
|
104
|
+
data_to_instance(klass, Puppet::Util::Json.load(text))
|
105
105
|
end
|
106
106
|
|
107
107
|
def intern_multiple(klass, text)
|
108
|
-
|
108
|
+
Puppet::Util::Json.load(text).collect do |data|
|
109
109
|
data_to_instance(klass, data)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
# JSON monkey-patches Array, so this works.
|
114
|
-
# https://github.com/ruby/ruby/blob/ruby_1_9_3/ext/json/generator/generator.c#L1416
|
115
113
|
def render_multiple(instances)
|
116
|
-
instances
|
114
|
+
Puppet::Util::Json.dump(instances)
|
117
115
|
end
|
118
116
|
|
119
117
|
# Unlike PSON, we do not need to unwrap the data envelope, because legacy 3.x agents
|
@@ -162,7 +160,7 @@ Puppet::Network::FormatHandler.create(:console,
|
|
162
160
|
end
|
163
161
|
|
164
162
|
# ...or pretty-print the inspect outcome.
|
165
|
-
|
163
|
+
Puppet::Util::Json.dump(datum, :pretty => true, :quirks_mode => true)
|
166
164
|
end
|
167
165
|
|
168
166
|
def render_multiple(data)
|
@@ -13,8 +13,6 @@ module Puppet::Network::HTTP
|
|
13
13
|
require 'puppet/network/http/error'
|
14
14
|
require 'puppet/network/http/route'
|
15
15
|
require 'puppet/network/http/api'
|
16
|
-
require 'puppet/network/http/api/ca'
|
17
|
-
require 'puppet/network/http/api/ca/v1'
|
18
16
|
require 'puppet/network/http/api/master'
|
19
17
|
require 'puppet/network/http/api/master/v3'
|
20
18
|
require 'puppet/network/http/handler'
|
@@ -20,8 +20,7 @@ class Puppet::Network::HTTP::API
|
|
20
20
|
"or point them to a server running Puppet 3.\n\n" +
|
21
21
|
"Master Info:\n" +
|
22
22
|
" Puppet version: #{Puppet.version}\n" +
|
23
|
-
" Supported /puppet API versions: #{Puppet::Network::HTTP::MASTER_URL_VERSIONS}\n"
|
24
|
-
" Supported /puppet-ca API versions: #{Puppet::Network::HTTP::CA_URL_VERSIONS}",
|
23
|
+
" Supported /puppet API versions: #{Puppet::Network::HTTP::MASTER_URL_VERSIONS}\n",
|
25
24
|
Puppet::Network::HTTP::Issues::HANDLER_NOT_FOUND)
|
26
25
|
end)
|
27
26
|
end
|
@@ -33,12 +32,4 @@ class Puppet::Network::HTTP::API
|
|
33
32
|
chain(Puppet::Network::HTTP::API::Master::V3.routes,
|
34
33
|
Puppet::Network::HTTP::API.not_found)
|
35
34
|
end
|
36
|
-
|
37
|
-
def self.ca_routes
|
38
|
-
ca_prefix = Regexp.new("^#{Puppet::Network::HTTP::CA_URL_PREFIX}/")
|
39
|
-
Puppet::Network::HTTP::Route.path(ca_prefix).
|
40
|
-
any.
|
41
|
-
chain(Puppet::Network::HTTP::API::CA::V1.routes,
|
42
|
-
Puppet::Network::HTTP::API.not_found)
|
43
|
-
end
|
44
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
require 'puppet/parser/environment_compiler'
|
3
3
|
|
4
4
|
class Puppet::Network::HTTP::API::Master::V3::Environment
|
@@ -15,7 +15,7 @@ class Puppet::Network::HTTP::API::Master::V3::Environment
|
|
15
15
|
|
16
16
|
env_graph = build_environment_graph(catalog)
|
17
17
|
|
18
|
-
response.respond_with(200, "application/json",
|
18
|
+
response.respond_with(200, "application/json", Puppet::Util::Json.dump(env_graph))
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_environment_graph(catalog)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
|
3
3
|
class Puppet::Network::HTTP::API::Master::V3::Environments
|
4
4
|
def initialize(env_loader)
|
@@ -6,7 +6,7 @@ class Puppet::Network::HTTP::API::Master::V3::Environments
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(request, response)
|
9
|
-
response.respond_with(200, "application/json",
|
9
|
+
response.respond_with(200, "application/json", Puppet::Util::Json.dump({
|
10
10
|
"search_paths" => @env_loader.search_paths,
|
11
11
|
"environments" => Hash[@env_loader.list.collect do |env|
|
12
12
|
[env.name, {
|
@@ -32,7 +32,7 @@ module Puppet::Network::HTTP::Compression
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def uncompress(response)
|
35
|
-
raise Net::HTTPError.new("No block passed") unless block_given?
|
35
|
+
raise Net::HTTPError.new("No block passed", response) unless block_given?
|
36
36
|
|
37
37
|
case response['content-encoding']
|
38
38
|
when 'gzip','deflate'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'net/https'
|
2
2
|
require 'puppet/ssl/host'
|
3
|
-
require 'puppet/ssl/configuration'
|
4
3
|
require 'puppet/ssl/validator'
|
5
4
|
require 'puppet/network/http'
|
6
5
|
require 'uri'
|
7
6
|
require 'date'
|
7
|
+
require 'time'
|
8
8
|
|
9
9
|
module Puppet::Network::HTTP
|
10
10
|
|
@@ -297,7 +297,14 @@ module Puppet::Network::HTTP
|
|
297
297
|
end
|
298
298
|
|
299
299
|
def execute_request(connection, request)
|
300
|
+
start = Time.now
|
300
301
|
connection.request(request)
|
302
|
+
rescue EOFError => e
|
303
|
+
elapsed = (Time.now - start).to_f.round(3)
|
304
|
+
uri = @site.addr + request.path.split('?')[0]
|
305
|
+
eof = EOFError.new(_('request %{uri} interrupted after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
|
306
|
+
eof.set_backtrace(e.backtrace) unless e.backtrace.empty?
|
307
|
+
raise eof
|
301
308
|
end
|
302
309
|
|
303
310
|
def with_connection(site, &block)
|
@@ -314,8 +321,9 @@ module Puppet::Network::HTTP
|
|
314
321
|
msg = error.message
|
315
322
|
msg << ": [" + @verify.verify_errors.join('; ') + "]"
|
316
323
|
raise Puppet::Error, msg, error.backtrace
|
317
|
-
elsif peer_cert && !OpenSSL::SSL.verify_certificate_identity(peer_cert
|
318
|
-
valid_certnames = [peer_cert.
|
324
|
+
elsif peer_cert && !OpenSSL::SSL.verify_certificate_identity(peer_cert, site.host)
|
325
|
+
valid_certnames = [peer_cert.subject.to_s.sub(/.*=/, ''),
|
326
|
+
*Puppet::SSL::Certificate.subject_alt_names_for(peer_cert)].uniq
|
319
327
|
if valid_certnames.size > 1
|
320
328
|
expected_certnames = _("expected one of %{certnames}") % { certnames: valid_certnames.join(', ') }
|
321
329
|
else
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
|
3
3
|
module Puppet::Network::HTTP::Error
|
4
4
|
Issues = Puppet::Network::HTTP::Issues
|
@@ -13,7 +13,7 @@ module Puppet::Network::HTTP::Error
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_json
|
16
|
-
|
16
|
+
Puppet::Util::Json.dump({:message => message, :issue_kind => @issue_kind})
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -67,7 +67,7 @@ module Puppet::Network::HTTP::Error
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def to_json
|
70
|
-
|
70
|
+
Puppet::Util::Json.dump({:message => message, :issue_kind => @issue_kind})
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -12,6 +12,8 @@ require 'puppet/util/http_proxy'
|
|
12
12
|
class Puppet::Network::HTTP::Factory
|
13
13
|
@@openssl_initialized = false
|
14
14
|
|
15
|
+
KEEP_ALIVE_TIMEOUT = 2**31 - 1
|
16
|
+
|
15
17
|
def initialize
|
16
18
|
# PUP-1411, make sure that openssl is initialized before we try to connect
|
17
19
|
if ! @@openssl_initialized
|
@@ -37,6 +39,7 @@ class Puppet::Network::HTTP::Factory
|
|
37
39
|
http.use_ssl = site.use_ssl?
|
38
40
|
http.read_timeout = Puppet[:http_read_timeout]
|
39
41
|
http.open_timeout = Puppet[:http_connect_timeout]
|
42
|
+
http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT if http.respond_to?(:keep_alive_timeout=)
|
40
43
|
|
41
44
|
if Puppet[:sourceaddress]
|
42
45
|
if http.respond_to?(:local_host)
|
@@ -44,42 +44,78 @@ module Puppet::Network::HTTP::Handler
|
|
44
44
|
format.is_a?(Puppet::Network::Format) ? format.mime : format
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
request_headers = headers(request)
|
52
|
-
request_params = params(request)
|
53
|
-
request_method = http_method(request)
|
47
|
+
# Create a generic puppet request from the implementation-specific request
|
48
|
+
# created by the web server
|
49
|
+
def make_generic_request(request)
|
54
50
|
request_path = path(request)
|
55
51
|
|
56
|
-
|
52
|
+
Puppet::Network::HTTP::Request.new(
|
53
|
+
headers(request),
|
54
|
+
params(request),
|
55
|
+
http_method(request),
|
56
|
+
request_path, # path
|
57
|
+
request_path, # routing_path
|
58
|
+
client_cert(request),
|
59
|
+
body(request)
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def with_request_profiling(request)
|
64
|
+
profiler = configure_profiler(request.headers, request.params)
|
65
|
+
|
66
|
+
Puppet::Util::Profiler.profile(
|
67
|
+
_("Processed request %{request_method} %{request_path}") % { request_method: request.method, request_path: request.path },
|
68
|
+
[:http, request.method, request.path]
|
69
|
+
) do
|
70
|
+
yield
|
71
|
+
end
|
72
|
+
ensure
|
73
|
+
remove_profiler(profiler) if profiler
|
74
|
+
end
|
57
75
|
|
58
|
-
|
76
|
+
# handle an HTTP request
|
77
|
+
def process(external_request, response)
|
78
|
+
# The response_wrapper stores the response and modifies it as a side effect.
|
79
|
+
# The caller will use the original response
|
80
|
+
response_wrapper = Puppet::Network::HTTP::Response.new(self, response)
|
81
|
+
request = make_generic_request(external_request)
|
59
82
|
|
60
|
-
|
83
|
+
set_puppet_version_header(response)
|
61
84
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
else
|
66
|
-
raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(_("No route for %{request} %{path}") % { request: new_request.method, path: new_request.path }, HANDLER_NOT_FOUND)
|
85
|
+
respond_to_errors(response_wrapper) do
|
86
|
+
with_request_profiling(request) do
|
87
|
+
find_route_or_raise(request).process(request, response_wrapper)
|
67
88
|
end
|
68
89
|
end
|
90
|
+
end
|
69
91
|
|
92
|
+
def respond_to_errors(response)
|
93
|
+
yield
|
70
94
|
rescue Puppet::Network::HTTP::Error::HTTPError => e
|
71
95
|
Puppet.info(e.message)
|
72
|
-
|
96
|
+
respond_with_http_error(response, e)
|
73
97
|
rescue StandardError => e
|
74
98
|
http_e = Puppet::Network::HTTP::Error::HTTPServerError.new(e)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
99
|
+
Puppet.err([http_e.message, *e.backtrace].join("\n"))
|
100
|
+
respond_with_http_error(response, http_e)
|
101
|
+
end
|
102
|
+
|
103
|
+
def respond_with_http_error(response, exception)
|
104
|
+
response.respond_with(exception.status, "application/json", exception.to_json)
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_route_or_raise(request)
|
108
|
+
if route = @routes.find { |r| r.matches?(request) }
|
109
|
+
return route
|
110
|
+
else
|
111
|
+
raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(
|
112
|
+
_("No route for %{request} %{path}") % { request: request.method, path: request.path },
|
113
|
+
HANDLER_NOT_FOUND)
|
81
114
|
end
|
82
|
-
|
115
|
+
end
|
116
|
+
|
117
|
+
def set_puppet_version_header(response)
|
118
|
+
response[Puppet::Network::HTTP::HEADER_PUPPET_VERSION] = Puppet.version
|
83
119
|
end
|
84
120
|
|
85
121
|
# Set the response up, with the body and status.
|
@@ -131,10 +167,6 @@ module Puppet::Network::HTTP::Handler
|
|
131
167
|
raise NotImplementedError
|
132
168
|
end
|
133
169
|
|
134
|
-
def cleanup(request)
|
135
|
-
# By default, there is nothing to cleanup.
|
136
|
-
end
|
137
|
-
|
138
170
|
def decode_params(params)
|
139
171
|
params.select { |key, _| allowed_parameter?(key) }.inject({}) do |result, ary|
|
140
172
|
param, value = ary
|
@@ -1,85 +1,158 @@
|
|
1
1
|
require 'resolv'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
|
3
|
+
module Puppet::Network
|
4
|
+
class Resolver
|
5
|
+
|
6
|
+
class CacheEntry
|
7
|
+
attr_reader :records, :ttl, :resolution_time
|
8
|
+
|
9
|
+
def initialize(records)
|
10
|
+
@records = records
|
11
|
+
@resolution_time = Time.now
|
12
|
+
@ttl = choose_lowest_ttl(records)
|
13
|
+
end
|
14
|
+
|
15
|
+
def choose_lowest_ttl(records)
|
16
|
+
ttl = records.first.ttl
|
17
|
+
records.each do |rec|
|
18
|
+
if rec.ttl < ttl
|
19
|
+
ttl = rec.ttl
|
20
|
+
end
|
21
|
+
end
|
22
|
+
ttl
|
23
|
+
end
|
12
24
|
end
|
13
25
|
|
14
|
-
|
26
|
+
def initialize
|
27
|
+
@resolver = Resolv::DNS.new
|
15
28
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when :file then service = '_x-puppet-fileserver'
|
21
|
-
else service = "_x-puppet-#{service_name.to_s}"
|
29
|
+
# Stores DNS records per service, along with their TTL
|
30
|
+
# and the time at which they were resolved, for cache
|
31
|
+
# eviction.
|
32
|
+
@record_cache = {}
|
22
33
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
|
35
|
+
# Iterate through the list of records for this service
|
36
|
+
# and yield each server and port pair. Records are only fetched
|
37
|
+
# via DNS query the first time and cached for the duration of their
|
38
|
+
# service's TTL thereafter.
|
39
|
+
# @param [String] domain the domain to search for
|
40
|
+
# @param [Symbol] service_name the key of the service we are querying
|
41
|
+
# @yields [String, Integer] server and port of selected record
|
42
|
+
def each_srv_record(domain, service_name = :puppet, &block)
|
43
|
+
if (domain.nil? or domain.empty?)
|
44
|
+
Puppet.debug "Domain not known; skipping SRV lookup"
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
Puppet.debug "Searching for SRV records for domain: #{domain}"
|
49
|
+
|
50
|
+
case service_name
|
51
|
+
when :puppet then service = '_x-puppet'
|
52
|
+
when :file then service = '_x-puppet-fileserver'
|
53
|
+
else service = "_x-puppet-#{service_name.to_s}"
|
54
|
+
end
|
55
|
+
record_name = "#{service}._tcp.#{domain}"
|
56
|
+
|
57
|
+
if @record_cache.has_key?(service_name) && !expired?(service_name)
|
58
|
+
records = @record_cache[service_name].records
|
59
|
+
Puppet.debug "Using cached record for #{record_name}"
|
60
|
+
else
|
61
|
+
records = @resolver.getresources(record_name, Resolv::DNS::Resource::IN::SRV)
|
62
|
+
if records.size > 0
|
63
|
+
@record_cache[service_name] = CacheEntry.new(records)
|
64
|
+
end
|
65
|
+
Puppet.debug "Found #{records.size} SRV records for: #{record_name}"
|
66
|
+
end
|
67
|
+
|
68
|
+
if records.size == 0 && service_name != :puppet
|
69
|
+
# Try the generic :puppet service if no SRV records were found
|
70
|
+
# for the specific service.
|
71
|
+
each_srv_record(domain, :puppet, &block)
|
72
|
+
else
|
73
|
+
each_priority(records) do |recs|
|
74
|
+
while next_rr = recs.delete(find_weighted_server(recs))
|
75
|
+
Puppet.debug "Yielding next server of #{next_rr.target.to_s}:#{next_rr.port}"
|
76
|
+
yield next_rr.target.to_s, next_rr.port
|
77
|
+
end
|
38
78
|
end
|
39
79
|
end
|
40
80
|
end
|
41
|
-
end
|
42
81
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
82
|
+
# Given a list of records of the same priority, chooses a random one
|
83
|
+
# from among them, favoring those with higher weights.
|
84
|
+
# @param [[Resolv::DNS::Resource::IN::SRV]] records a list of records
|
85
|
+
# of the same priority
|
86
|
+
# @return [Resolv::DNS::Resource::IN:SRV] the chosen record
|
87
|
+
def find_weighted_server(records)
|
88
|
+
return nil if records.nil? || records.empty?
|
89
|
+
return records.first if records.size == 1
|
90
|
+
|
91
|
+
# Calculate the sum of all weights in the list of resource records,
|
92
|
+
# This is used to then select hosts until the weight exceeds what
|
93
|
+
# random number we selected. For example, if we have weights of 1 8 and 3:
|
94
|
+
#
|
95
|
+
# |-|--------|---|
|
96
|
+
# ^
|
97
|
+
# We generate a random number 5, and iterate through the records, adding
|
98
|
+
# the current record's weight to the accumulator until the weight of the
|
99
|
+
# current record plus previous records is greater than the random number.
|
100
|
+
total_weight = records.inject(0) { |sum,record|
|
101
|
+
sum + weight(record)
|
102
|
+
}
|
103
|
+
current_weight = 0
|
104
|
+
chosen_weight = 1 + Kernel.rand(total_weight)
|
105
|
+
|
106
|
+
records.each do |record|
|
107
|
+
current_weight += weight(record)
|
108
|
+
return record if current_weight >= chosen_weight
|
109
|
+
end
|
48
110
|
end
|
49
111
|
|
50
|
-
|
51
|
-
|
112
|
+
def weight(record)
|
113
|
+
record.weight == 0 ? 1 : record.weight * 10
|
52
114
|
end
|
53
|
-
end
|
54
|
-
private_class_method :each_priority
|
55
115
|
|
56
|
-
|
57
|
-
|
58
|
-
return
|
116
|
+
# Returns TTL for the cached records for this service.
|
117
|
+
# @param [String] service_name the service whose TTL we want
|
118
|
+
# @return [Integer] the TTL for this service, in seconds
|
119
|
+
def ttl(service_name)
|
120
|
+
return @record_cache[service_name].ttl
|
121
|
+
end
|
59
122
|
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
total_weight = records.inject(0) { |sum,record|
|
71
|
-
sum + weight(record)
|
72
|
-
}
|
73
|
-
current_weight = 0
|
74
|
-
chosen_weight = 1 + Kernel.rand(total_weight)
|
75
|
-
|
76
|
-
records.each do |record|
|
77
|
-
current_weight += weight(record)
|
78
|
-
return record if current_weight >= chosen_weight
|
123
|
+
# Checks if the cached entry for the given service has expired.
|
124
|
+
# @param [String] service_name the name of the service to check
|
125
|
+
# @return [Boolean] true if the entry has expired, false otherwise.
|
126
|
+
# Always returns true if the record had no TTL.
|
127
|
+
def expired?(service_name)
|
128
|
+
if entry = @record_cache[service_name]
|
129
|
+
return Time.now > (entry.resolution_time + entry.ttl)
|
130
|
+
else
|
131
|
+
return true
|
132
|
+
end
|
79
133
|
end
|
80
|
-
end
|
81
134
|
|
82
|
-
|
83
|
-
|
135
|
+
private
|
136
|
+
|
137
|
+
# Groups the records by their priority and yields the groups
|
138
|
+
# in order of highest to lowest priority (lowest to highest numbers),
|
139
|
+
# one at a time.
|
140
|
+
# { 1 => [records], 2 => [records], etc. }
|
141
|
+
#
|
142
|
+
# @param [[Resolv::DNS::Resource::IN::SRV]] records the list of
|
143
|
+
# records for a given service
|
144
|
+
# @yields [[Resolv::DNS::Resource::IN::SRV]] a group of records of
|
145
|
+
# the same priority
|
146
|
+
def each_priority(records)
|
147
|
+
pri_hash = records.inject({}) do |groups, element|
|
148
|
+
groups[element.priority] ||= []
|
149
|
+
groups[element.priority] << element
|
150
|
+
groups
|
151
|
+
end
|
152
|
+
|
153
|
+
pri_hash.keys.sort.each do |key|
|
154
|
+
yield pri_hash[key]
|
155
|
+
end
|
156
|
+
end
|
84
157
|
end
|
85
158
|
end
|