puppet 6.18.0-x86-mingw32 → 6.19.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -10
  3. data/README.md +1 -2
  4. data/Rakefile +4 -12
  5. data/lib/puppet/agent/locker.rb +0 -7
  6. data/lib/puppet/application/agent.rb +8 -3
  7. data/lib/puppet/application/doc.rb +1 -1
  8. data/lib/puppet/application/lookup.rb +5 -5
  9. data/lib/puppet/configurer.rb +39 -7
  10. data/lib/puppet/defaults.rb +55 -29
  11. data/lib/puppet/environments.rb +51 -10
  12. data/lib/puppet/face/catalog.rb +1 -1
  13. data/lib/puppet/face/config.rb +46 -16
  14. data/lib/puppet/face/node.rb +3 -3
  15. data/lib/puppet/face/node/clean.rb +2 -2
  16. data/lib/puppet/face/status.rb +1 -1
  17. data/lib/puppet/file_bucket/dipper.rb +1 -1
  18. data/lib/puppet/functions/new.rb +8 -3
  19. data/lib/puppet/http.rb +1 -0
  20. data/lib/puppet/http/client.rb +1 -1
  21. data/lib/puppet/http/resolver.rb +5 -8
  22. data/lib/puppet/http/resolver/server_list.rb +18 -36
  23. data/lib/puppet/http/resolver/settings.rb +4 -4
  24. data/lib/puppet/http/resolver/srv.rb +5 -5
  25. data/lib/puppet/http/service.rb +3 -1
  26. data/lib/puppet/http/service/compiler.rb +1 -1
  27. data/lib/puppet/http/service/file_server.rb +1 -1
  28. data/lib/puppet/http/service/puppetserver.rb +39 -0
  29. data/lib/puppet/http/session.rb +5 -4
  30. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  31. data/lib/puppet/indirector/facts/yaml.rb +1 -1
  32. data/lib/puppet/indirector/json.rb +1 -1
  33. data/lib/puppet/indirector/msgpack.rb +1 -1
  34. data/lib/puppet/indirector/request.rb +4 -4
  35. data/lib/puppet/indirector/yaml.rb +1 -1
  36. data/lib/puppet/network/http/api/master/v3/environments.rb +0 -1
  37. data/lib/puppet/node/facts.rb +17 -0
  38. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  39. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  40. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  41. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  42. data/lib/puppet/provider/package/dpkg.rb +1 -1
  43. data/lib/puppet/provider/package/pip2.rb +17 -0
  44. data/lib/puppet/provider/package/puppetserver_gem.rb +180 -0
  45. data/lib/puppet/provider/package/yum.rb +1 -0
  46. data/lib/puppet/resource/type.rb +2 -1
  47. data/lib/puppet/rest/route.rb +2 -2
  48. data/lib/puppet/settings.rb +19 -5
  49. data/lib/puppet/transaction/report.rb +11 -7
  50. data/lib/puppet/type/file/source.rb +1 -1
  51. data/lib/puppet/type/filebucket.rb +1 -1
  52. data/lib/puppet/util/connection.rb +8 -8
  53. data/lib/puppet/util/run_mode.rb +5 -1
  54. data/lib/puppet/version.rb +1 -1
  55. data/locales/puppet.pot +153 -156
  56. data/man/man5/puppet.conf.5 +29 -13
  57. data/man/man8/puppet-agent.8 +6 -3
  58. data/man/man8/puppet-apply.8 +1 -1
  59. data/man/man8/puppet-catalog.8 +1 -1
  60. data/man/man8/puppet-config.8 +6 -6
  61. data/man/man8/puppet-describe.8 +1 -1
  62. data/man/man8/puppet-device.8 +1 -1
  63. data/man/man8/puppet-doc.8 +1 -1
  64. data/man/man8/puppet-epp.8 +1 -1
  65. data/man/man8/puppet-facts.8 +1 -1
  66. data/man/man8/puppet-filebucket.8 +1 -1
  67. data/man/man8/puppet-generate.8 +1 -1
  68. data/man/man8/puppet-help.8 +1 -1
  69. data/man/man8/puppet-key.8 +1 -1
  70. data/man/man8/puppet-lookup.8 +1 -1
  71. data/man/man8/puppet-man.8 +1 -1
  72. data/man/man8/puppet-module.8 +1 -1
  73. data/man/man8/puppet-node.8 +4 -4
  74. data/man/man8/puppet-parser.8 +1 -1
  75. data/man/man8/puppet-plugin.8 +1 -1
  76. data/man/man8/puppet-report.8 +1 -1
  77. data/man/man8/puppet-resource.8 +1 -1
  78. data/man/man8/puppet-script.8 +1 -1
  79. data/man/man8/puppet-ssl.8 +1 -1
  80. data/man/man8/puppet-status.8 +2 -2
  81. data/man/man8/puppet.8 +2 -2
  82. data/spec/fixtures/unit/provider/package/puppetserver_gem/gem-list-local-packages +30 -0
  83. data/spec/integration/application/agent_spec.rb +23 -19
  84. data/spec/integration/application/filebucket_spec.rb +7 -7
  85. data/spec/integration/application/plugin_spec.rb +3 -3
  86. data/spec/integration/configurer_spec.rb +14 -0
  87. data/spec/integration/defaults_spec.rb +26 -1
  88. data/spec/integration/util/windows/adsi_spec.rb +2 -2
  89. data/spec/shared_contexts/types_setup.rb +2 -0
  90. data/spec/unit/application/doc_spec.rb +2 -2
  91. data/spec/unit/application/facts_spec.rb +3 -1
  92. data/spec/unit/application_spec.rb +9 -4
  93. data/spec/unit/configurer_spec.rb +39 -6
  94. data/spec/unit/environments_spec.rb +99 -32
  95. data/spec/unit/face/config_spec.rb +56 -0
  96. data/spec/unit/face/node_spec.rb +2 -2
  97. data/spec/unit/file_system_spec.rb +1 -2
  98. data/spec/unit/http/resolver_spec.rb +24 -4
  99. data/spec/unit/http/service/ca_spec.rb +2 -2
  100. data/spec/unit/http/service/compiler_spec.rb +2 -2
  101. data/spec/unit/http/service/file_server_spec.rb +2 -2
  102. data/spec/unit/http/service/puppetserver_spec.rb +82 -0
  103. data/spec/unit/http/service/report_spec.rb +2 -2
  104. data/spec/unit/http/session_spec.rb +8 -20
  105. data/spec/unit/indirector/catalog/json_spec.rb +1 -1
  106. data/spec/unit/indirector/catalog/rest_spec.rb +1 -1
  107. data/spec/unit/indirector/facts/rest_spec.rb +1 -1
  108. data/spec/unit/indirector/json_spec.rb +8 -8
  109. data/spec/unit/indirector/msgpack_spec.rb +8 -8
  110. data/spec/unit/indirector/node/rest_spec.rb +1 -1
  111. data/spec/unit/indirector/request_spec.rb +4 -4
  112. data/spec/unit/indirector/rest_spec.rb +1 -1
  113. data/spec/unit/indirector/status/rest_spec.rb +1 -1
  114. data/spec/unit/indirector/yaml_spec.rb +7 -7
  115. data/spec/unit/network/http/api/master/v3/environments_spec.rb +12 -23
  116. data/spec/unit/provider/exec_spec.rb +4 -3
  117. data/spec/unit/provider/package/dpkg_spec.rb +22 -7
  118. data/spec/unit/provider/package/openbsd_spec.rb +2 -0
  119. data/spec/unit/provider/package/pip2_spec.rb +36 -0
  120. data/spec/unit/provider/package/puppetserver_gem_spec.rb +137 -0
  121. data/spec/unit/provider/package/yum_spec.rb +31 -0
  122. data/spec/unit/provider/service/base_spec.rb +2 -4
  123. data/spec/unit/provider/service/bsd_spec.rb +5 -1
  124. data/spec/unit/provider/service/daemontools_spec.rb +1 -1
  125. data/spec/unit/provider/service/debian_spec.rb +3 -5
  126. data/spec/unit/provider/service/freebsd_spec.rb +1 -1
  127. data/spec/unit/provider/service/gentoo_spec.rb +4 -5
  128. data/spec/unit/provider/service/init_spec.rb +4 -5
  129. data/spec/unit/provider/service/launchd_spec.rb +5 -6
  130. data/spec/unit/provider/service/openrc_spec.rb +4 -5
  131. data/spec/unit/provider/service/openwrt_spec.rb +1 -1
  132. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  133. data/spec/unit/provider/service/runit_spec.rb +2 -1
  134. data/spec/unit/provider/service/smf_spec.rb +1 -1
  135. data/spec/unit/provider/service/src_spec.rb +3 -5
  136. data/spec/unit/provider/service/systemd_spec.rb +3 -1
  137. data/spec/unit/provider/service/upstart_spec.rb +4 -5
  138. data/spec/unit/rest/route_spec.rb +4 -4
  139. data/spec/unit/settings_spec.rb +44 -22
  140. data/spec/unit/transaction/report_spec.rb +2 -0
  141. data/spec/unit/type/file/source_spec.rb +1 -1
  142. data/spec/unit/type/filebucket_spec.rb +1 -1
  143. data/spec/unit/util/run_mode_spec.rb +6 -6
  144. metadata +13 -2
@@ -97,7 +97,7 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do
97
97
  A serialized catalog.
98
98
  EOT
99
99
  when_invoked do |*args|
100
- Puppet.settings.preferred_run_mode = :master
100
+ Puppet.settings.preferred_run_mode = :server
101
101
  Puppet::Face[:catalog, :current].find(*args)
102
102
  end
103
103
  end
@@ -20,10 +20,10 @@ Puppet::Face.define(:config, '0.0.1') do
20
20
  description <<-EOT
21
21
  The section of the puppet.conf configuration file to interact with.
22
22
 
23
- The three most commonly used sections are 'main', 'master', and 'agent'.
23
+ The three most commonly used sections are 'main', 'server', and 'agent'.
24
24
  'Main' is the default, and is used by all Puppet applications. Other
25
25
  sections can override 'main' values for specific applications --- the
26
- 'master' section affects Puppet Server, and the 'agent'
26
+ 'server' section affects Puppet Server, and the 'agent'
27
27
  section affects puppet agent.
28
28
 
29
29
  Less commonly used is the 'user' section, which affects puppet apply. Any
@@ -52,9 +52,9 @@ Puppet::Face.define(:config, '0.0.1') do
52
52
 
53
53
  $ puppet config print rundir
54
54
 
55
- Get a list of important directories from the master's config:
55
+ Get a list of important directories from the server's config:
56
56
 
57
- $ puppet config print all --section master | grep -E "(path|dir)"
57
+ $ puppet config print all --section server | grep -E "(path|dir)"
58
58
  EOT
59
59
 
60
60
  when_invoked do |*args|
@@ -144,7 +144,7 @@ Puppet::Face.define(:config, '0.0.1') do
144
144
 
145
145
  if name == 'environment' && options[:section] == 'main'
146
146
  Puppet.warning _(<<-EOM).chomp
147
- The environment should be set in either the `[user]`, `[agent]`, or `[master]`
147
+ The environment should be set in either the `[user]`, `[agent]`, or `[server]`
148
148
  section. Variables set in the `[agent]` section are used when running
149
149
  `puppet agent`. Variables set in the `[user]` section are used when running
150
150
  various other puppet subcommands, like `puppet apply` and `puppet module`; these
@@ -163,7 +163,24 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
163
163
  Puppet::FileSystem.touch(path)
164
164
  Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file|
165
165
  Puppet::Settings::IniFile.update(file) do |config|
166
- config.set(options[:section], name, value)
166
+ if options[:section] == "master"
167
+ # delete requested master section if it exists,
168
+ # as server section should be used
169
+ setting_string = config.delete("master", name)
170
+ if setting_string
171
+
172
+ if Puppet::Util::Log.sendlevel?(:info)
173
+ report_section_and_environment(options[:section], Puppet.settings[:environment])
174
+ end
175
+
176
+ puts(_("Deleted setting from '%{section_name}': '%{setting_string}', and adding it to 'server' section") %
177
+ { section_name: options[:section], name: name, setting_string: setting_string.strip })
178
+ end
179
+ # add the setting to the to server section instead of master section
180
+ config.set("server", name, value)
181
+ else
182
+ config.set(options[:section], name, value)
183
+ end
167
184
  end
168
185
  end
169
186
  nil
@@ -185,9 +202,9 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
185
202
 
186
203
  $ puppet config delete setting_name
187
204
 
188
- Delete the setting 'setting_name' from the 'master' configuration domain:
205
+ Delete the setting 'setting_name' from the 'server' configuration domain:
189
206
 
190
- $ puppet config delete setting_name --section master
207
+ $ puppet config delete setting_name --section server
191
208
  EOT
192
209
 
193
210
  when_invoked do |name, options|
@@ -202,18 +219,31 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
202
219
  if Puppet::FileSystem.exist?(path)
203
220
  Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file|
204
221
  Puppet::Settings::IniFile.update(file) do |config|
205
- setting_string = config.delete(options[:section], name)
206
- if setting_string
207
222
 
208
- if Puppet::Util::Log.sendlevel?(:info)
209
- report_section_and_environment(options[:section], Puppet.settings[:environment])
210
- end
223
+ # delete from both master section and server section
224
+ if options[:section] == "master" || options[:section] == "server"
225
+ master_setting_string = config.delete("master", name)
226
+ puts(_("Deleted setting from '%{section_name}': '%{setting_string}'") %
227
+ { section_name: 'master', name: name, setting_string: master_setting_string.strip[/[^=]+/] }) if master_setting_string
211
228
 
229
+ server_setting_string = config.delete("server", name)
212
230
  puts(_("Deleted setting from '%{section_name}': '%{setting_string}'") %
213
- { section_name: options[:section], name: name, setting_string: setting_string.strip })
231
+ { section_name: 'server', name: name, setting_string: server_setting_string.strip[/[^=]+/] }) if server_setting_string
232
+
214
233
  else
215
- Puppet.warning(_("No setting found in configuration file for section '%{section_name}' setting name '%{name}'") %
216
- { section_name: options[:section], name: name })
234
+ setting_string = config.delete(options[:section], name)
235
+ if setting_string
236
+
237
+ if Puppet::Util::Log.sendlevel?(:info)
238
+ report_section_and_environment(options[:section], Puppet.settings[:environment])
239
+ end
240
+
241
+ puts(_("Deleted setting from '%{section_name}': '%{setting_string}'") %
242
+ { section_name: options[:section], name: name, setting_string: setting_string.strip })
243
+ else
244
+ Puppet.warning(_("No setting found in configuration file for section '%{section_name}' setting name '%{name}'") %
245
+ { section_name: options[:section], name: name })
246
+ end
217
247
  end
218
248
  end
219
249
  end
@@ -32,11 +32,11 @@ Puppet::Indirector::Face.define(:node, '0.0.1') do
32
32
 
33
33
  $ puppet node find somenode.puppetlabs.lan --terminus plain --render-as yaml
34
34
 
35
- Retrieve a node using the puppet master's configured ENC:
35
+ Retrieve a node using the Puppet Server's configured ENC:
36
36
 
37
- $ puppet node find somenode.puppetlabs.lan --terminus exec --run_mode master --render-as yaml
37
+ $ puppet node find somenode.puppetlabs.lan --terminus exec --run_mode server --render-as yaml
38
38
 
39
- Retrieve the same node from the puppet master:
39
+ Retrieve the same node from the Puppet Server:
40
40
 
41
41
  $ puppet node find somenode.puppetlabs.lan --terminus rest --render-as yaml
42
42
  EOT
@@ -26,9 +26,9 @@ Puppet::Face.define(:node, '0.0.1') do
26
26
  # definition, and should not be modifiable beyond that. This is one of
27
27
  # the only places left in the code that tries to manipulate it. Other
28
28
  # parts of code that handle certificates behave differently if the
29
- # run_mode is master. Those other behaviors are needed for cleaning the
29
+ # run_mode is server. Those other behaviors are needed for cleaning the
30
30
  # certificates correctly.
31
- Puppet.settings.preferred_run_mode = "master"
31
+ Puppet.settings.preferred_run_mode = "server"
32
32
 
33
33
  Puppet::Node::Facts.indirection.terminus_class = :yaml
34
34
  Puppet::Node::Facts.indirection.cache_class = :yaml
@@ -26,7 +26,7 @@ Puppet::Indirector::Face.define(:status, '0.0.1') do
26
26
 
27
27
  Over REST, this action will query the configured puppet master by default.
28
28
  To query other servers, including puppet agent nodes started with the
29
- <--listen> option, you can set the global <--server> and <--masterport>
29
+ <--listen> option, you can set the global <--server> and <--serverport>
30
30
  options on the command line; note that agent nodes listen on port 8139.
31
31
  EOT
32
32
  find.short_description <<-EOT
@@ -16,7 +16,7 @@ class Puppet::FileBucket::Dipper
16
16
  def initialize(hash = {})
17
17
  # Emulate the XMLRPC client
18
18
  server = hash[:Server]
19
- port = hash[:Port] || Puppet[:masterport]
19
+ port = hash[:Port] || Puppet[:serverport]
20
20
 
21
21
  if hash.include?(:Path)
22
22
  @local_path = hash[:Path]
@@ -991,12 +991,17 @@ Puppet::Functions.create_function(:new, Puppet::Functions::InternalFunction) do
991
991
 
992
992
  def new_instance(scope, t, *args)
993
993
  return args[0] if args.size == 1 && !t.is_a?(Puppet::Pops::Types::PInitType) && t.instance?(args[0])
994
- result = assert_type(t, new_function_for_type(t, scope).call(scope, *args))
994
+ result = assert_type(t, new_function_for_type(t).call(scope, *args))
995
995
  return block_given? ? yield(result) : result
996
996
  end
997
997
 
998
- def new_function_for_type(t, scope)
999
- @new_function_cache ||= Hash.new() {|hsh, key| hsh[key] = key.new_function.new(scope, loader) }
998
+ def new_function_for_type(t)
999
+ @new_function_cache ||= {}
1000
+
1001
+ unless @new_function_cache.key?(t)
1002
+ @new_function_cache[t] = t.new_function.new(nil, loader)
1003
+ end
1004
+
1000
1005
  @new_function_cache[t]
1001
1006
  end
1002
1007
 
@@ -22,6 +22,7 @@ module Puppet
22
22
  require 'puppet/http/service/ca'
23
23
  require 'puppet/http/service/compiler'
24
24
  require 'puppet/http/service/file_server'
25
+ require 'puppet/http/service/puppetserver'
25
26
  require 'puppet/http/service/report'
26
27
  require 'puppet/http/session'
27
28
  require 'puppet/http/resolver'
@@ -438,7 +438,7 @@ class Puppet::HTTP::Client
438
438
  services.delete(:report)
439
439
  end
440
440
 
441
- resolvers << Puppet::HTTP::Resolver::ServerList.new(self, server_list_setting: server_list_setting, default_port: Puppet[:masterport], services: services)
441
+ resolvers << Puppet::HTTP::Resolver::ServerList.new(self, server_list_setting: server_list_setting, default_port: Puppet[:serverport], services: services)
442
442
  end
443
443
 
444
444
  resolvers << Puppet::HTTP::Resolver::Settings.new(self)
@@ -28,12 +28,12 @@ class Puppet::HTTP::Resolver
28
28
  # @param [Symbol] name the service to resolve
29
29
  # @param [Puppet::SSL::SSLContext] ssl_context (nil) optional ssl context to
30
30
  # use when creating a connection
31
- # @param [Proc] error_handler (nil) optional callback for each error
32
- # encountered while resolving a route.
31
+ # @param [Proc] canceled_handler (nil) optional callback allowing a resolver
32
+ # to cancel resolution.
33
33
  #
34
34
  # @raise [NotImplementedError] this base class is not implemented
35
35
  #
36
- def resolve(session, name, ssl_context: nil, error_handler: nil)
36
+ def resolve(session, name, ssl_context: nil, canceled_handler: nil)
37
37
  raise NotImplementedError
38
38
  end
39
39
 
@@ -45,17 +45,14 @@ class Puppet::HTTP::Resolver
45
45
  # @param [Puppet::HTTP::Session] session
46
46
  # @param [Puppet::HTTP::Service] service
47
47
  # @param [Puppet::SSL::SSLContext] ssl_context
48
- # @param [Proc] error_handler (nil) optional callback for each error
49
- # encountered while resolving a route.
50
48
  #
51
49
  # @return [Boolean] Returns true if a connection is successful, false otherwise
52
50
  #
53
- def check_connection?(session, service, ssl_context: nil, error_handler: nil)
51
+ def check_connection?(session, service, ssl_context: nil)
54
52
  service.connect(ssl_context: ssl_context)
55
53
  return true
56
54
  rescue Puppet::HTTP::ConnectionError => e
57
- error_handler.call(e) if error_handler
58
- Puppet.debug("Connection to #{service.url} failed, trying next route: #{e.message}")
55
+ Puppet.log_exception(e, "Connection to #{service.url} failed, trying next route: #{e.message}")
59
56
  return false
60
57
  end
61
58
  end
@@ -22,7 +22,6 @@ class Puppet::HTTP::Resolver::ServerList < Puppet::HTTP::Resolver
22
22
  @server_list_setting = server_list_setting
23
23
  @default_port = default_port
24
24
  @services = services
25
- @resolved_url = nil
26
25
  end
27
26
 
28
27
  #
@@ -33,8 +32,8 @@ class Puppet::HTTP::Resolver::ServerList < Puppet::HTTP::Resolver
33
32
  # @param [Puppet::HTTP::Session] session <description>
34
33
  # @param [Symbol] name the name of the service being resolved
35
34
  # @param [Puppet::SSL::SSLContext] ssl_context
36
- # @param [Proc] error_handler (nil) optional callback for each error
37
- # encountered while resolving a route.
35
+ # @param [Proc] canceled_handler (nil) optional callback allowing a resolver
36
+ # to cancel resolution.
38
37
  #
39
38
  # @return [nil] return nil if the service to be resolved does not support
40
39
  # server_list
@@ -44,7 +43,7 @@ class Puppet::HTTP::Resolver::ServerList < Puppet::HTTP::Resolver
44
43
  # @raise [Puppet::Error] raise if none of the servers defined in server_list
45
44
  # are available
46
45
  #
47
- def resolve(session, name, ssl_context: nil, error_handler: nil)
46
+ def resolve(session, name, ssl_context: nil, canceled_handler: nil)
48
47
  # If we're configured to use an explicit service host, e.g. report_server
49
48
  # then don't use server_list to resolve the `:report` service.
50
49
  return nil unless @services.include?(name)
@@ -58,41 +57,24 @@ class Puppet::HTTP::Resolver::ServerList < Puppet::HTTP::Resolver
58
57
  @server_list_setting.value.each do |server|
59
58
  host = server[0]
60
59
  port = server[1] || @default_port
61
- uri = URI("https://#{host}:#{port}/status/v1/simple/master")
62
- if get_success?(uri, session, ssl_context: ssl_context, error_handler: error_handler)
63
- @resolved_url = uri
64
- return Puppet::HTTP::Service.create_service(@client, session, name, host, port)
60
+
61
+ service = Puppet::HTTP::Service.create_service(@client, session, :puppetserver, host, port)
62
+ begin
63
+ service.get_simple_status(ssl_context: ssl_context)
64
+ @resolved_url = service.url
65
+ return Puppet::HTTP::Service.create_service(@client, session, name, @resolved_url.host, @resolved_url.port)
66
+ rescue Puppet::HTTP::ResponseError => detail
67
+ Puppet.log_exception(detail, _("Puppet server %{host}:%{port} is unavailable: %{code} %{reason}") %
68
+ { host: service.url.host, port: service.url.port, code: detail.response.code, reason: detail.response.reason })
69
+ rescue Puppet::HTTP::HTTPError => detail
70
+ Puppet.log_exception(detail, _("Unable to connect to server from server_list setting: %{detail}") % {detail: detail})
65
71
  end
66
72
  end
67
73
 
68
- raise Puppet::Error, _("Could not select a functional puppet master from server_list: '%{server_list}'") % { server_list: @server_list_setting.print(@server_list_setting.value) }
69
- end
70
-
71
- #
72
- # @api private
73
- #
74
- # Check if a server and port is available
75
- #
76
- # @param [URI] uri A URI created from the server and port to test
77
- # @param [Puppet::HTTP::Session] session
78
- # @param [Puppet::SSL::SSLContext] ssl_context
79
- # @param [Proc] error_handler (nil) optional callback for each error
80
- # encountered while resolving a route.
81
- #
82
- # @return [Boolean] true if a successful response is returned by the server,
83
- # false otherwise
84
- #
85
- def get_success?(uri, session, ssl_context: nil, error_handler: nil)
86
- response = @client.get(uri, options: {ssl_context: ssl_context})
87
- return true if response.success?
74
+ # don't fallback to other resolvers
75
+ canceled_handler.call(true) if canceled_handler
88
76
 
89
- Puppet.debug(_("Puppet server %{host}:%{port} is unavailable: %{code} %{reason}") %
90
- { host: uri.host, port: uri.port, code: response.code, reason: response.reason })
91
- return false
92
- rescue => detail
93
- error_handler.call(detail) if error_handler
94
- #TRANSLATORS 'server_list' is the name of a setting and should not be translated
95
- Puppet.debug _("Unable to connect to server from server_list setting: %{detail}") % {detail: detail}
96
- return false
77
+ # not found
78
+ nil
97
79
  end
98
80
  end
@@ -13,14 +13,14 @@ class Puppet::HTTP::Resolver::Settings < Puppet::HTTP::Resolver
13
13
  # @param [Puppet::HTTP::Session] session
14
14
  # @param [Symbol] name the name of the service to be resolved
15
15
  # @param [Puppet::SSL::SSLContext] ssl_context
16
- # @param [Proc] error_handler (nil) optional callback for each error
17
- # encountered while resolving a route.
16
+ # @param [Proc] canceled_handler (nil) optional callback allowing a resolver
17
+ # to cancel resolution.
18
18
  #
19
19
  # @return [Puppet::HTTP::Service] if the service successfully connects,
20
20
  # return it. Otherwise, return nil.
21
21
  #
22
- def resolve(session, name, ssl_context: nil, error_handler: nil)
22
+ def resolve(session, name, ssl_context: nil, canceled_handler: nil)
23
23
  service = Puppet::HTTP::Service.create_service(@client, session, name)
24
- check_connection?(session, service, ssl_context: ssl_context, error_handler: error_handler) ? service : nil
24
+ check_connection?(session, service, ssl_context: ssl_context) ? service : nil
25
25
  end
26
26
  end
@@ -25,21 +25,21 @@ class Puppet::HTTP::Resolver::SRV < Puppet::HTTP::Resolver
25
25
  # @param [Puppet::HTTP::Session] session
26
26
  # @param [Symbol] name the service being resolved
27
27
  # @param [Puppet::SSL::SSLContext] ssl_context
28
- # @param [Proc] error_handler (nil) optional callback for each error
29
- # encountered while resolving a route.
28
+ # @param [Proc] canceled_handler (nil) optional callback allowing a resolver
29
+ # to cancel resolution.
30
30
  #
31
31
  # @return [Puppet::HTTP::Service] if an available service is found, return
32
32
  # it. Return nil otherwise.
33
33
  #
34
- def resolve(session, name, ssl_context: nil, error_handler: nil)
34
+ def resolve(session, name, ssl_context: nil, canceled_handler: nil)
35
35
  # Here we pass our HTTP service name as the DNS SRV service name
36
36
  # This is fine for :ca, but note that :puppet and :file are handled
37
37
  # specially in `each_srv_record`.
38
38
  @delegate.each_srv_record(@srv_domain, name) do |server, port|
39
39
  service = Puppet::HTTP::Service.create_service(@client, session, name, server, port)
40
- return service if check_connection?(session, service, ssl_context: ssl_context, error_handler: error_handler)
40
+ return service if check_connection?(session, service, ssl_context: ssl_context)
41
41
  end
42
42
 
43
- return nil
43
+ nil
44
44
  end
45
45
  end
@@ -10,7 +10,7 @@ class Puppet::HTTP::Service
10
10
 
11
11
  # @api private
12
12
  # @return [Array<Symbol>] available services
13
- SERVICE_NAMES = [:ca, :fileserver, :puppet, :report].freeze
13
+ SERVICE_NAMES = [:ca, :fileserver, :puppet, :puppetserver, :report].freeze
14
14
 
15
15
  # @api private
16
16
  # @return [Array<Symbol>] format types that are unsupported
@@ -43,6 +43,8 @@ class Puppet::HTTP::Service
43
43
  Puppet::HTTP::Service::FileServer.new(client, session, server, port)
44
44
  when :puppet
45
45
  ::Puppet::HTTP::Service::Compiler.new(client, session, server, port)
46
+ when :puppetserver
47
+ ::Puppet::HTTP::Service::Puppetserver.new(client, session, server, port)
46
48
  when :report
47
49
  Puppet::HTTP::Service::Report.new(client, session, server, port)
48
50
  else
@@ -22,7 +22,7 @@ class Puppet::HTTP::Service::Compiler < Puppet::HTTP::Service
22
22
  # create the service.
23
23
  #
24
24
  def initialize(client, session, server, port)
25
- url = build_url(API, server || Puppet[:server], port || Puppet[:masterport])
25
+ url = build_url(API, server || Puppet[:server], port || Puppet[:serverport])
26
26
  super(client, session, url)
27
27
  end
28
28
 
@@ -27,7 +27,7 @@ class Puppet::HTTP::Service::FileServer < Puppet::HTTP::Service
27
27
  # create the service.
28
28
  #
29
29
  def initialize(client, session, server, port)
30
- url = build_url(API, server || Puppet[:server], port || Puppet[:masterport])
30
+ url = build_url(API, server || Puppet[:server], port || Puppet[:serverport])
31
31
  super(client, session, url)
32
32
  end
33
33
 
@@ -0,0 +1,39 @@
1
+ # The puppetserver service.
2
+ #
3
+ # @api private
4
+ #
5
+ class Puppet::HTTP::Service::Puppetserver < Puppet::HTTP::Service
6
+ # @param [Puppet::HTTP::Client] client
7
+ # @param [Puppet::HTTP::Session] session
8
+ # @param [String] server If an explicit server is given,
9
+ # create a service using that server. If server is nil, the default value
10
+ # is used to create the service.
11
+ # @param [Integer] port If an explicit port is given, create
12
+ # a service using that port. If port is nil, the default value is used to
13
+ # create the service.
14
+ # @api private
15
+ #
16
+ def initialize(client, session, server, port)
17
+ url = build_url('', server || Puppet[:server], port || Puppet[:serverport])
18
+ super(client, session, url)
19
+ end
20
+
21
+ # Request the puppetserver's simple status
22
+ #
23
+ # @param [Puppet::SSL::SSLContext] ssl_context to use when establishing
24
+ # the connection.
25
+ # @return Puppet::HTTP::Response The HTTP response
26
+ # @api private
27
+ #
28
+ def get_simple_status(ssl_context: nil)
29
+ response = @client.get(
30
+ with_base_url("/status/v1/simple/master"),
31
+ headers: add_puppet_headers({}),
32
+ options: {ssl_context: ssl_context}
33
+ )
34
+
35
+ process_response(response)
36
+
37
+ [response, response.body.to_s]
38
+ end
39
+ end