bolt 0.21.1 → 0.21.2

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

Potentially problematic release.


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

Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/lib/bolt/applicator.rb +56 -0
  3. data/lib/bolt/error.rb +6 -0
  4. data/lib/bolt/pal.rb +8 -1
  5. data/lib/bolt/transport/winrm.rb +4 -1
  6. data/lib/bolt/version.rb +1 -1
  7. data/libexec/apply_catalog.rb +61 -0
  8. data/{exe → libexec}/bolt_catalog +0 -0
  9. data/vendored/puppet/lib/puppet/application.rb +8 -1
  10. data/vendored/puppet/lib/puppet/application/device.rb +24 -28
  11. data/vendored/puppet/lib/puppet/application/doc.rb +4 -2
  12. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -2
  13. data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
  14. data/vendored/puppet/lib/puppet/defaults.rb +2 -6
  15. data/vendored/puppet/lib/puppet/environments.rb +4 -10
  16. data/vendored/puppet/lib/puppet/error.rb +1 -1
  17. data/vendored/puppet/lib/puppet/etc.rb +4 -5
  18. data/vendored/puppet/lib/puppet/face/config.rb +1 -1
  19. data/vendored/puppet/lib/puppet/face/module/build.rb +5 -55
  20. data/vendored/puppet/lib/puppet/face/module/generate.rb +5 -247
  21. data/vendored/puppet/lib/puppet/gettext/config.rb +28 -5
  22. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +5 -7
  23. data/vendored/puppet/lib/puppet/indirector/rest.rb +7 -56
  24. data/vendored/puppet/lib/puppet/indirector/terminus.rb +1 -1
  25. data/vendored/puppet/lib/puppet/interface.rb +1 -1
  26. data/vendored/puppet/lib/puppet/interface/face_collection.rb +3 -1
  27. data/vendored/puppet/lib/puppet/metatype/manager.rb +2 -2
  28. data/vendored/puppet/lib/puppet/module_tool/applications.rb +0 -1
  29. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +1 -1
  30. data/vendored/puppet/lib/puppet/network/http/connection.rb +2 -23
  31. data/vendored/puppet/lib/puppet/network/http/factory.rb +2 -6
  32. data/vendored/puppet/lib/puppet/node.rb +1 -2
  33. data/vendored/puppet/lib/puppet/node/environment.rb +5 -1
  34. data/vendored/puppet/lib/puppet/parser/functions.rb +35 -3
  35. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +12 -0
  36. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -5
  37. data/vendored/puppet/lib/puppet/pops/model/ast.rb +107 -0
  38. data/vendored/puppet/lib/puppet/pops/model/factory.rb +11 -0
  39. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  40. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1519 -1485
  41. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  42. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +1 -1
  43. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
  44. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +1 -2
  45. data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -24
  46. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +5 -0
  47. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +31 -4
  48. data/vendored/puppet/lib/puppet/provider.rb +12 -1
  49. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +2 -1
  50. data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +1 -1
  51. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  52. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +3 -1
  53. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +2 -0
  54. data/vendored/puppet/lib/puppet/reference/configuration.rb +6 -0
  55. data/vendored/puppet/lib/puppet/reports.rb +2 -2
  56. data/vendored/puppet/lib/puppet/resource/status.rb +2 -0
  57. data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
  58. data/vendored/puppet/lib/puppet/rest/client.rb +28 -24
  59. data/vendored/puppet/lib/puppet/rest/response.rb +5 -0
  60. data/vendored/puppet/lib/puppet/rest/route.rb +13 -31
  61. data/vendored/puppet/lib/puppet/rest/routes.rb +65 -5
  62. data/vendored/puppet/lib/puppet/rest/ssl_context.rb +13 -0
  63. data/vendored/puppet/lib/puppet/settings.rb +6 -0
  64. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -2
  65. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +5 -1
  66. data/vendored/puppet/lib/puppet/ssl/host.rb +148 -43
  67. data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
  68. data/vendored/puppet/lib/puppet/test/test_helper.rb +3 -0
  69. data/vendored/puppet/lib/puppet/transaction/event_manager.rb +3 -1
  70. data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
  71. data/vendored/puppet/lib/puppet/type.rb +2 -2
  72. data/vendored/puppet/lib/puppet/type/file/content.rb +2 -3
  73. data/vendored/puppet/lib/puppet/type/schedule.rb +33 -84
  74. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  75. data/vendored/puppet/lib/puppet/util.rb +5 -0
  76. data/vendored/puppet/lib/puppet/util/autoload.rb +39 -31
  77. data/vendored/puppet/lib/puppet/util/character_encoding.rb +0 -22
  78. data/vendored/puppet/lib/puppet/util/command_line.rb +0 -1
  79. data/vendored/puppet/lib/puppet/util/connection.rb +74 -0
  80. data/vendored/puppet/lib/puppet/util/feature.rb +2 -2
  81. data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -19
  82. data/vendored/puppet/lib/puppet/util/json.rb +0 -8
  83. data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
  84. data/vendored/puppet/lib/puppet/util/network_device/base.rb +1 -1
  85. data/vendored/puppet/lib/puppet/util/platform.rb +3 -0
  86. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  87. data/vendored/puppet/lib/puppet/util/reference.rb +2 -2
  88. data/vendored/puppet/lib/puppet/util/rubygems.rb +1 -13
  89. data/vendored/puppet/lib/puppet/util/ssl.rb +40 -1
  90. data/vendored/puppet/lib/puppet/util/windows.rb +1 -0
  91. data/vendored/puppet/lib/puppet/util/windows/file.rb +18 -0
  92. data/vendored/puppet/lib/puppet/util/windows/security.rb +26 -14
  93. metadata +8 -73
  94. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +0 -152
  95. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +0 -1
  96. data/vendored/puppet/lib/puppet/provider/mailalias/aliases.rb +0 -50
  97. data/vendored/puppet/lib/puppet/provider/maillist/mailman.rb +0 -108
  98. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +0 -108
  99. data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +0 -364
  100. data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +0 -125
  101. data/vendored/puppet/lib/puppet/type/mailalias.rb +0 -46
  102. data/vendored/puppet/lib/puppet/type/maillist.rb +0 -62
  103. data/vendored/puppet/lib/puppet/type/zfs.rb +0 -154
  104. data/vendored/puppet/lib/puppet/type/zone.rb +0 -382
  105. data/vendored/puppet/lib/puppet/type/zpool.rb +0 -91
@@ -1,256 +1,14 @@
1
1
  Puppet::Face.define(:module, '1.0.0') do
2
2
  action(:generate) do
3
3
  summary _("Generate boilerplate for a new module.")
4
- description <<-EOT
5
- Generates boilerplate for a new module by creating the directory
6
- structure and files recommended for the Puppet community's best practices.
4
+ #TRANSLATORS 'Puppet Development Kit' is the name of the software package replacing this action and should not be translated.
5
+ description _("This action has been replaced by Puppet Development Kit. For more information visit https://puppet.com/docs/pdk/latest/pdk.html.")
7
6
 
8
- A module may need additional directories beyond this boilerplate
9
- if it provides plugins, files, or templates.
10
- EOT
11
-
12
- returns _("Array of Pathname objects representing paths of generated files.")
13
-
14
- examples <<-EOT
15
- Generate a new module in the current directory:
16
-
17
- $ puppet module generate puppetlabs-ssh
18
- We need to create a metadata.json file for this module. Please answer the
19
- following questions; if the question is not applicable to this module, feel free
20
- to leave it blank.
21
-
22
- Puppet uses Semantic Versioning (semver.org) to version modules.
23
- What version is this module? [0.1.0]
24
- -->
25
-
26
- Who wrote this module? [puppetlabs]
27
- -->
28
-
29
- What license does this module code fall under? [Apache-2.0]
30
- -->
31
-
32
- How would you describe this module in a single sentence?
33
- -->
34
-
35
- Where is this module's source code repository?
36
- -->
37
-
38
- Where can others go to learn more about this module?
39
- -->
40
-
41
- Where can others go to file issues about this module?
42
- -->
43
-
44
- ----------------------------------------
45
- {
46
- "name": "puppetlabs-ssh",
47
- "version": "0.1.0",
48
- "author": "puppetlabs",
49
- "summary": null,
50
- "license": "Apache-2.0",
51
- "source": "",
52
- "project_page": null,
53
- "issues_url": null,
54
- "dependencies": [
55
- {
56
- "name": "puppetlabs-stdlib",
57
- "version_requirement": ">= 1.0.0"
58
- }
59
- ]
60
- }
61
- ----------------------------------------
62
-
63
- About to generate this metadata; continue? [n/Y]
64
- -->
65
-
66
- Notice: Generating module at /Users/username/Projects/puppet/puppetlabs-ssh...
67
- Notice: Populating ERB templates...
68
- Finished; module generated in puppetlabs-ssh.
69
- puppetlabs-ssh/manifests
70
- puppetlabs-ssh/manifests/init.pp
71
- puppetlabs-ssh/metadata.json
72
- puppetlabs-ssh/README.md
73
- puppetlabs-ssh/spec
74
- puppetlabs-ssh/spec/spec_helper.rb
75
- puppetlabs-ssh/tests
76
- puppetlabs-ssh/tests/init.pp
77
- EOT
78
-
79
- option "--skip-interview" do
80
- summary _("Bypass the interactive metadata interview")
81
- description <<-EOT
82
- Do not attempt to perform a metadata interview. Primarily useful for automatic
83
- execution of `puppet module generate`.
84
- EOT
85
- end
86
-
87
- arguments _("<name>")
88
-
89
- when_invoked do |name, options|
90
- # Since we only want to interview if it's being rendered to the console
91
- # (i.e. when invoked with `puppet module generate`), we can't do any work
92
- # here in the when_invoked block. The result of this block is then
93
- # passed to each renderer, which will handle it appropriately; by
94
- # returning a simple message like this, every renderer will simply output
95
- # the string.
96
- # Our `when_rendering :console` handler will ignore this value and
97
- # actually generate the module.
98
- #
99
- # All this is necessary because it is not possible at this point in time
100
- # to know what the destination of the output is.
101
- _("This format is not supported by this action.")
102
- end
103
-
104
- when_rendering :console do |_, name, options|
105
- Puppet::ModuleTool.set_option_defaults options
106
-
107
- begin
108
- # A default dependency for all newly generated modules is being
109
- # introduced as a substitute for the comments we used to include in the
110
- # previous module data specifications. While introducing a default
111
- # dependency is less than perfectly desirable, the cost is low, and the
112
- # syntax is obtuse enough to justify its inclusion.
113
- metadata = Puppet::ModuleTool::Metadata.new.update(
114
- 'name' => name,
115
- 'version' => '0.1.0',
116
- 'dependencies' => [
117
- { 'name' => 'puppetlabs-stdlib', 'version_requirement' => '>= 1.0.0' }
118
- ]
119
- )
120
- rescue ArgumentError
121
- msg = _("Could not generate directory %{name}, you must specify a dash-separated username and module name.") % { name: name.inspect }
122
- raise ArgumentError, msg, $!.backtrace
123
- end
124
-
125
- dest = Puppet::ModuleTool::Generate.destination(metadata)
126
- result = Puppet::ModuleTool::Generate.generate(metadata, options[:skip_interview])
127
-
128
- path = dest.relative_path_from(Pathname.pwd)
129
- puts _("Finished; module generated in %{path}.") % { path: path }
130
- result.join("\n")
7
+ when_invoked do |*args|
8
+ #TRANSLATORS 'Puppet Development Kit' is the name of the software package replacing this action and should not be translated.
9
+ raise _("This action has been replaced by Puppet Development Kit. For more information visit https://puppet.com/docs/pdk/latest/pdk.html.")
131
10
  end
132
11
 
133
12
  deprecate
134
13
  end
135
14
  end
136
-
137
- module Puppet::ModuleTool::Generate
138
- module_function
139
-
140
- def generate(metadata, skip_interview = false)
141
- #TRANSLATORS 'puppet module generate' is the name of the puppet command and 'Puppet Development Kit' is the name of the software package replacing this action and should not be translated.
142
- Puppet.deprecation_warning _("`puppet module generate` is deprecated and will be removed in a future release. This action has been replaced by Puppet Development Kit. For more information visit https://puppet.com/docs/pdk/latest/pdk.html.")
143
-
144
- interview(metadata) unless skip_interview
145
- destination = duplicate_skeleton(metadata)
146
- all_files = destination.basename + '**/*'
147
-
148
- return Dir[all_files.to_s]
149
- end
150
-
151
- def interview(metadata)
152
- puts _("We need to create a metadata.json file for this module. Please answer the
153
- following questions; if the question is not applicable to this module, feel free
154
- to leave it blank.")
155
-
156
- begin
157
- puts
158
- puts _("Puppet uses Semantic Versioning (semver.org) to version modules.")
159
- puts _("What version is this module? [%{version}]") % { version: metadata.version }
160
- metadata.update 'version' => user_input(metadata.version)
161
- rescue
162
- Puppet.err _("We're sorry, we could not parse that as a Semantic Version.")
163
- retry
164
- end
165
-
166
- puts
167
- puts _("Who wrote this module? [%{author}]") % { author: metadata.author }
168
- metadata.update 'author' => user_input(metadata.author)
169
-
170
- puts
171
- puts _("What license does this module code fall under? [%{license}]") % { license: metadata.license }
172
- metadata.update 'license' => user_input(metadata.license)
173
-
174
- puts
175
- puts _("How would you describe this module in a single sentence?")
176
- metadata.update 'summary' => user_input(metadata.summary)
177
-
178
- puts
179
- puts _("Where is this module's source code repository?")
180
- metadata.update 'source' => user_input(metadata.source)
181
-
182
- puts
183
- puts _("Where can others go to learn more about this module?%{project_page}") % { project_page: metadata.project_page && " [#{metadata.project_page}]" }
184
- metadata.update 'project_page' => user_input(metadata.project_page)
185
-
186
- puts
187
- puts _("Where can others go to file issues about this module?%{issues}") % { issues: metadata.issues_url && " [#{metadata.issues_url}]" }
188
- metadata.update 'issues_url' => user_input(metadata.issues_url)
189
-
190
- puts
191
- puts '-' * 40
192
- puts metadata.to_json
193
- puts '-' * 40
194
- puts
195
- puts _("About to generate this metadata; continue? [n/Y]")
196
-
197
- if user_input('Y') !~ /^y(es)?$/i
198
- puts _("Aborting...")
199
- exit 0
200
- end
201
- end
202
-
203
- def user_input(default=nil)
204
- print '--> '
205
- input = STDIN.gets.chomp.strip
206
- input = default if input == ''
207
- return input
208
- end
209
-
210
- def destination(metadata)
211
- return @dest if defined? @dest
212
- @dest = Pathname.pwd + metadata.name
213
- raise ArgumentError, _("%{destination} already exists.") % { destination: @dest } if @dest.exist?
214
- return @dest
215
- end
216
-
217
- def duplicate_skeleton(metadata)
218
- dest = destination(metadata)
219
-
220
- puts
221
- Puppet.notice _("Generating module at %{dest}...") % { dest: dest }
222
- FileUtils.cp_r skeleton_path, dest
223
-
224
- populate_templates(metadata, dest)
225
- return dest
226
- end
227
-
228
- def populate_templates(metadata, destination)
229
- Puppet.notice _("Populating templates...")
230
-
231
- formatters = {
232
- :erb => proc { |data, ctx| ERB.new(data).result(ctx) },
233
- :template => proc { |data, _| data },
234
- }
235
-
236
- formatters.each do |type, block|
237
- templates = destination + "**/*.#{type}"
238
-
239
- Dir.glob(templates.to_s, File::FNM_DOTMATCH).each do |erb|
240
- path = Pathname.new(erb)
241
- content = block[path.read, binding]
242
-
243
- target = path.parent + path.basename(".#{type}")
244
- target.open('w:UTF-8') { |f| f.write(content) }
245
- path.unlink
246
- end
247
- end
248
- end
249
-
250
- def skeleton_path
251
- return @path if defined? @path
252
- path = Pathname(Puppet.settings[:module_skeleton_dir])
253
- path = Pathname(__FILE__).dirname + '../../module_tool/skeleton/templates/generator' unless path.directory?
254
- @path = path
255
- end
256
- end
@@ -6,6 +6,7 @@ module Puppet::GettextConfig
6
6
  POSIX_PATH = File.absolute_path('../../../../../share/locale', File.dirname(__FILE__))
7
7
  WINDOWS_PATH = File.absolute_path('../../../../../../../puppet/share/locale', File.dirname(__FILE__))
8
8
 
9
+ # This is the only domain name that won't be a symbol, making it unique from environments.
9
10
  DEFAULT_TEXT_DOMAIN = 'default-text-domain'
10
11
 
11
12
  # Load gettext helpers and track whether they're available.
@@ -59,10 +60,12 @@ module Puppet::GettextConfig
59
60
  # Clears the translation repository for the given text domain,
60
61
  # creating it if it doesn't exist, then adds default translations
61
62
  # and switches to using this domain.
62
- # @param [String] domain_name the name of the domain to create
63
+ # @param [String, Symbol] domain_name the name of the domain to create
63
64
  def self.reset_text_domain(domain_name)
64
65
  return if @gettext_disabled || !gettext_loaded?
66
+ domain_name = domain_name.to_sym
65
67
 
68
+ Puppet.debug "Reset text domain to #{domain_name.inspect}"
66
69
  FastGettext.add_text_domain(domain_name,
67
70
  type: :chain,
68
71
  chain: [],
@@ -71,6 +74,18 @@ module Puppet::GettextConfig
71
74
  FastGettext.text_domain = domain_name
72
75
  end
73
76
 
77
+ # @api private
78
+ # Resets the thread's configured text_domain to the default text domain.
79
+ # In Puppet Server, thread A may process a compile request that configures
80
+ # a domain, while thread B may invalidate that environment and delete the
81
+ # domain. That leaves thread A with an invalid text_domain selected.
82
+ # To avoid that, clear_text_domain after any processing that needs the
83
+ # non-default text domain.
84
+ def self.clear_text_domain
85
+ return if @gettext_disabled || !gettext_loaded?
86
+ FastGettext.text_domain = nil
87
+ end
88
+
74
89
  # @api private
75
90
  # Creates a default text domain containing the translations for
76
91
  # Puppet as the start of chain. When semantic_puppet gets initialized,
@@ -94,12 +109,16 @@ module Puppet::GettextConfig
94
109
 
95
110
  # @api private
96
111
  # Switches the active text domain, if the requested domain exists.
97
- # @param [String] domain_name the name of the domain to switch to
112
+ # @param [String, Symbol] domain_name the name of the domain to switch to
98
113
  def self.use_text_domain(domain_name)
99
114
  return if @gettext_disabled || !gettext_loaded?
115
+ domain_name = domain_name.to_sym
100
116
 
101
117
  if FastGettext.translation_repositories.include?(domain_name)
118
+ Puppet.debug "Use text domain #{domain_name.inspect}"
102
119
  FastGettext.text_domain = domain_name
120
+ else
121
+ Puppet.debug "Requested unknown text domain #{domain_name.inspect}"
103
122
  end
104
123
  end
105
124
 
@@ -113,13 +132,17 @@ module Puppet::GettextConfig
113
132
 
114
133
  # @api private
115
134
  # Deletes the text domain with the given name
116
- # @param [String] domain_name the name of the domain to delete
135
+ # @param [String, Symbol] domain_name the name of the domain to delete
117
136
  def self.delete_text_domain(domain_name)
118
137
  return if @gettext_disabled || !gettext_loaded?
138
+ domain_name = domain_name.to_sym
119
139
 
120
- FastGettext.translation_repositories.delete(domain_name)
140
+ deleted = FastGettext.translation_repositories.delete(domain_name)
121
141
  if FastGettext.text_domain == domain_name
142
+ Puppet.debug "Deleted current text domain #{domain_name.inspect}: #{!deleted.nil?}"
122
143
  FastGettext.text_domain = nil
144
+ else
145
+ Puppet.debug "Deleted text domain #{domain_name.inspect}: #{!deleted.nil?}"
123
146
  end
124
147
  end
125
148
 
@@ -145,7 +168,7 @@ module Puppet::GettextConfig
145
168
  # Since we are currently (Nov 2017) vendoring semantic_puppet, in normal
146
169
  # flows these translations will be copied along with Puppet's.
147
170
  #
148
- # @param [String] domain_name the name of the domain to add translations to
171
+ # @param [Symbol] domain_name the name of the domain to add translations to
149
172
  def self.copy_default_translations(domain_name)
150
173
  return if @gettext_disabled || !gettext_loaded?
151
174
 
@@ -49,14 +49,12 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
49
49
  node = node_from_request(facts, request)
50
50
  node.trusted_data = Puppet.lookup(:trusted_information) { Puppet::Context::TrustedInformation.local(node) }.to_h
51
51
 
52
- node.environment.use_text_domain if node.environment
53
-
54
- if catalog = compile(node, request.options)
55
- return catalog
52
+ if node.environment
53
+ node.environment.with_text_domain do
54
+ compile(node, request.options)
55
+ end
56
56
  else
57
- # This shouldn't actually happen; we should either return
58
- # a config or raise an exception.
59
- return nil
57
+ compile(node, request.options)
60
58
  end
61
59
  end
62
60
 
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
3
  require 'puppet/util/json'
4
+ require 'puppet/util/connection'
4
5
  require 'semantic_puppet'
5
6
 
6
7
  require 'puppet/network/http'
@@ -39,66 +40,16 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
39
40
  @srv_service || :puppet
40
41
  end
41
42
 
42
- # The logic for server and port is kind of gross. In summary:
43
- # IF an endpoint-specific setting is requested AND that setting has been set by the user
44
- # Use that setting.
45
- # The defaults for these settings are the "normal" server/masterport settings, so
46
- # when they are unset we instead want to "fall back" to the failover-selected
47
- # host/port pair.
48
- # ELSE IF we have a failover-selected host/port
49
- # Use what the failover logic came up with
50
- # ELSE IF the server_list setting is in use
51
- # Use the first entry - failover hasn't happened yet, but that
52
- # setting is still authoritative
53
- # ELSE
54
- # Go for the legacy server/masterport settings, and hope for the best
43
+ # Select the server to use based on the settings configuration
44
+ # for this indirection, taking into account the HA server list.
55
45
  def self.server
56
- setting = server_setting()
57
- if setting && setting != :server && Puppet.settings.set_by_config?(setting)
58
- Puppet.settings[setting]
59
- else
60
- server = Puppet.lookup(:server) do
61
- if primary_server = Puppet.settings[:server_list][0]
62
- Puppet.debug "Dynamically-bound server lookup failed; using first entry"
63
- primary_server[0]
64
- else
65
- setting ||= :server
66
- Puppet.debug "Dynamically-bound server lookup failed, falling back to #{setting} setting"
67
- Puppet.settings[setting]
68
- end
69
- end
70
- server
71
- end
46
+ Puppet::Util::Connection.determine_server(server_setting)
72
47
  end
73
48
 
74
- # For port there's a little bit of an extra snag: setting a specific
75
- # server setting and relying on the default port for that server is
76
- # common, so we also want to check if the assocaited SERVER setting
77
- # has been set by the user. If either of those are set we ignore the
78
- # failover-selected port.
49
+ # Select the port to use based on the settings configuration
50
+ # for this indirection, taking into account the HA server list.
79
51
  def self.port
80
- setting = port_setting()
81
- srv_setting = server_setting()
82
- if (setting && setting != :masterport && Puppet.settings.set_by_config?(setting)) ||
83
- (srv_setting && srv_setting != :server && Puppet.settings.set_by_config?(srv_setting))
84
- Puppet.settings[setting].to_i
85
- else
86
- port = Puppet.lookup(:serverport) do
87
- if primary_server = Puppet.settings[:server_list][0]
88
- Puppet.debug "Dynamically-bound port lookup failed; using first entry"
89
-
90
- # Port might not be set, so we want to fallback in that
91
- # case. We know we don't need to use `setting` here, since
92
- # the default value of every port setting is `masterport`
93
- (primary_server[1] || Puppet.settings[:masterport])
94
- else
95
- setting ||= :masterport
96
- Puppet.debug "Dynamically-bound port lookup failed; falling back to #{setting} setting"
97
- Puppet.settings[setting]
98
- end
99
- end
100
- port.to_i
101
- end
52
+ Puppet::Util::Connection.determine_port(port_setting, server_setting)
102
53
  end
103
54
 
104
55
  # Provide appropriate headers.
@@ -112,7 +112,7 @@ class Puppet::Indirector::Terminus
112
112
  # Return all terminus classes for a given indirection.
113
113
  def terminus_classes(indirection_name)
114
114
  setup_instance_loading indirection_name
115
- instance_loader(indirection_name).files_to_load.map do |file|
115
+ instance_loader(indirection_name).files_to_load(Puppet.lookup(:current_environment)).map do |file|
116
116
  File.basename(file).chomp(".rb").intern
117
117
  end
118
118
  end