puppet 6.14.0-x64-mingw32 → 6.15.0-x64-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 (195) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/ext/windows/service/daemon.rb +3 -3
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/agent.rb +2 -10
  6. data/lib/puppet/application/agent.rb +2 -1
  7. data/lib/puppet/application/filebucket.rb +5 -14
  8. data/lib/puppet/application/ssl.rb +2 -2
  9. data/lib/puppet/configurer.rb +7 -3
  10. data/lib/puppet/configurer/plugin_handler.rb +1 -1
  11. data/lib/puppet/defaults.rb +22 -2
  12. data/lib/puppet/environments.rb +4 -5
  13. data/lib/puppet/face/plugin.rb +1 -1
  14. data/lib/puppet/file_system/file_impl.rb +13 -9
  15. data/lib/puppet/forge/repository.rb +1 -1
  16. data/lib/puppet/functions/call.rb +1 -1
  17. data/lib/puppet/functions/reduce.rb +2 -4
  18. data/lib/puppet/http.rb +2 -0
  19. data/lib/puppet/http/client.rb +191 -52
  20. data/lib/puppet/http/external_client.rb +96 -0
  21. data/lib/puppet/http/redirector.rb +34 -0
  22. data/lib/puppet/http/resolver.rb +46 -3
  23. data/lib/puppet/http/resolver/server_list.rb +75 -15
  24. data/lib/puppet/http/resolver/settings.rb +22 -2
  25. data/lib/puppet/http/resolver/srv.rb +28 -2
  26. data/lib/puppet/http/response.rb +63 -1
  27. data/lib/puppet/http/retry_after_handler.rb +39 -0
  28. data/lib/puppet/http/service.rb +67 -1
  29. data/lib/puppet/http/service/ca.rb +71 -9
  30. data/lib/puppet/http/service/compiler.rb +213 -11
  31. data/lib/puppet/http/service/file_server.rb +105 -4
  32. data/lib/puppet/http/service/report.rb +36 -3
  33. data/lib/puppet/http/session.rb +59 -8
  34. data/lib/puppet/indirector/catalog/rest.rb +2 -1
  35. data/lib/puppet/indirector/facts/rest.rb +2 -1
  36. data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
  37. data/lib/puppet/indirector/file_metadata/rest.rb +4 -2
  38. data/lib/puppet/indirector/node/rest.rb +2 -1
  39. data/lib/puppet/indirector/report/yaml.rb +23 -0
  40. data/lib/puppet/indirector/status/rest.rb +2 -1
  41. data/lib/puppet/metatype/manager.rb +80 -80
  42. data/lib/puppet/network/http/base_pool.rb +6 -1
  43. data/lib/puppet/network/http/pool.rb +2 -4
  44. data/lib/puppet/network/http_pool.rb +1 -0
  45. data/lib/puppet/node/environment.rb +11 -1
  46. data/lib/puppet/pal/pal_impl.rb +1 -29
  47. data/lib/puppet/parser/compiler.rb +14 -7
  48. data/lib/puppet/parser/functions.rb +18 -13
  49. data/lib/puppet/pops/loaders.rb +7 -5
  50. data/lib/puppet/provider/group/windows_adsi.rb +3 -3
  51. data/lib/puppet/provider/package/apt.rb +61 -1
  52. data/lib/puppet/provider/package/dnfmodule.rb +39 -12
  53. data/lib/puppet/provider/package/gem.rb +41 -7
  54. data/lib/puppet/provider/package/pacman.rb +2 -5
  55. data/lib/puppet/provider/package/pip.rb +105 -33
  56. data/lib/puppet/provider/package/pip3.rb +0 -2
  57. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  58. data/lib/puppet/provider/package/pkgng.rb +16 -4
  59. data/lib/puppet/provider/package/puppet_gem.rb +6 -2
  60. data/lib/puppet/provider/package/rpm.rb +6 -213
  61. data/lib/puppet/provider/package/yum.rb +92 -19
  62. data/lib/puppet/provider/service/systemd.rb +2 -1
  63. data/lib/puppet/reports/http.rb +13 -11
  64. data/lib/puppet/resource/type_collection.rb +20 -16
  65. data/lib/puppet/ssl.rb +1 -0
  66. data/lib/puppet/ssl/host.rb +4 -4
  67. data/lib/puppet/ssl/oids.rb +1 -0
  68. data/lib/puppet/ssl/state_machine.rb +50 -33
  69. data/lib/puppet/transaction/report.rb +2 -2
  70. data/lib/puppet/type.rb +6 -1
  71. data/lib/puppet/type/file/source.rb +4 -2
  72. data/lib/puppet/type/package.rb +25 -2
  73. data/lib/puppet/type/user.rb +0 -19
  74. data/lib/puppet/util/at_fork.rb +1 -1
  75. data/lib/puppet/util/autoload.rb +3 -0
  76. data/lib/puppet/util/instance_loader.rb +14 -10
  77. data/lib/puppet/util/package/version/debian.rb +175 -0
  78. data/lib/puppet/util/package/version/gem.rb +15 -0
  79. data/lib/puppet/util/package/version/pip.rb +167 -0
  80. data/lib/puppet/util/package/version/range.rb +50 -0
  81. data/lib/puppet/util/package/version/range/gt.rb +14 -0
  82. data/lib/puppet/util/package/version/range/gt_eq.rb +14 -0
  83. data/lib/puppet/util/package/version/range/lt.rb +14 -0
  84. data/lib/puppet/util/package/version/range/lt_eq.rb +14 -0
  85. data/lib/puppet/util/package/version/range/min_max.rb +21 -0
  86. data/lib/puppet/util/package/version/range/simple.rb +11 -0
  87. data/lib/puppet/util/package/version/rpm.rb +73 -0
  88. data/lib/puppet/util/pidlock.rb +13 -7
  89. data/lib/puppet/util/platform.rb +5 -0
  90. data/lib/puppet/util/rpm_compare.rb +193 -0
  91. data/lib/puppet/util/windows/adsi.rb +2 -2
  92. data/lib/puppet/util/windows/process.rb +15 -14
  93. data/lib/puppet/util/windows/security.rb +1 -0
  94. data/lib/puppet/util/windows/sid.rb +3 -3
  95. data/lib/puppet/version.rb +1 -1
  96. data/locales/puppet.pot +207 -201
  97. data/man/man5/puppet.conf.5 +11 -3
  98. data/man/man8/puppet-agent.8 +1 -1
  99. data/man/man8/puppet-apply.8 +1 -1
  100. data/man/man8/puppet-catalog.8 +1 -1
  101. data/man/man8/puppet-config.8 +1 -1
  102. data/man/man8/puppet-describe.8 +1 -1
  103. data/man/man8/puppet-device.8 +1 -1
  104. data/man/man8/puppet-doc.8 +1 -1
  105. data/man/man8/puppet-epp.8 +1 -1
  106. data/man/man8/puppet-facts.8 +1 -1
  107. data/man/man8/puppet-filebucket.8 +1 -1
  108. data/man/man8/puppet-generate.8 +1 -1
  109. data/man/man8/puppet-help.8 +1 -1
  110. data/man/man8/puppet-key.8 +1 -1
  111. data/man/man8/puppet-lookup.8 +1 -1
  112. data/man/man8/puppet-man.8 +1 -1
  113. data/man/man8/puppet-module.8 +1 -1
  114. data/man/man8/puppet-node.8 +1 -1
  115. data/man/man8/puppet-parser.8 +1 -1
  116. data/man/man8/puppet-plugin.8 +1 -1
  117. data/man/man8/puppet-report.8 +1 -1
  118. data/man/man8/puppet-resource.8 +1 -1
  119. data/man/man8/puppet-script.8 +1 -1
  120. data/man/man8/puppet-ssl.8 +1 -1
  121. data/man/man8/puppet-status.8 +1 -1
  122. data/man/man8/puppet.8 +2 -2
  123. data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +67 -0
  124. data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -0
  125. data/spec/fixtures/ssl/unknown-ca-key.pem +67 -0
  126. data/spec/fixtures/ssl/unknown-ca.pem +59 -0
  127. data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list-enabled.txt} +2 -0
  128. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
  129. data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
  130. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
  131. data/spec/integration/application/agent_spec.rb +329 -0
  132. data/spec/integration/application/apply_spec.rb +132 -3
  133. data/spec/integration/application/filebucket_spec.rb +190 -0
  134. data/spec/integration/application/plugin_spec.rb +50 -0
  135. data/spec/integration/http/client_spec.rb +34 -40
  136. data/spec/integration/indirector/report/yaml.rb +83 -0
  137. data/spec/integration/module_tool/forge_spec.rb +2 -15
  138. data/spec/integration/network/http_pool_spec.rb +11 -19
  139. data/spec/integration/node/environment_spec.rb +15 -0
  140. data/spec/integration/util/windows/adsi_spec.rb +1 -1
  141. data/spec/lib/puppet/test_ca.rb +2 -2
  142. data/spec/lib/puppet_spec/https.rb +10 -7
  143. data/spec/lib/puppet_spec/puppetserver.rb +119 -0
  144. data/spec/shared_contexts/https.rb +29 -0
  145. data/spec/unit/agent_spec.rb +33 -25
  146. data/spec/unit/application/agent_spec.rb +5 -1
  147. data/spec/unit/application/device_spec.rb +2 -2
  148. data/spec/unit/application/filebucket_spec.rb +22 -2
  149. data/spec/unit/configurer_spec.rb +1 -1
  150. data/spec/unit/defaults_spec.rb +24 -1
  151. data/spec/unit/environments_spec.rb +8 -0
  152. data/spec/unit/file_system_spec.rb +10 -0
  153. data/spec/unit/http/client_spec.rb +105 -46
  154. data/spec/unit/http/external_client_spec.rb +201 -0
  155. data/spec/unit/http/resolver_spec.rb +20 -0
  156. data/spec/unit/http/service/ca_spec.rb +25 -2
  157. data/spec/unit/http/service/compiler_spec.rb +184 -6
  158. data/spec/unit/http/service/file_server_spec.rb +35 -3
  159. data/spec/unit/http/service/report_spec.rb +3 -1
  160. data/spec/unit/http/service_spec.rb +3 -3
  161. data/spec/unit/http/session_spec.rb +56 -7
  162. data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
  163. data/spec/unit/network/http/pool_spec.rb +3 -3
  164. data/spec/unit/node/environment_spec.rb +16 -0
  165. data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
  166. data/spec/unit/provider/package/apt_spec.rb +30 -0
  167. data/spec/unit/provider/package/dnfmodule_spec.rb +33 -14
  168. data/spec/unit/provider/package/gem_spec.rb +40 -0
  169. data/spec/unit/provider/package/pacman_spec.rb +6 -21
  170. data/spec/unit/provider/package/pip_spec.rb +26 -3
  171. data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
  172. data/spec/unit/provider/package/pkgng_spec.rb +38 -0
  173. data/spec/unit/provider/package/puppet_gem_spec.rb +8 -0
  174. data/spec/unit/provider/package/rpm_spec.rb +0 -212
  175. data/spec/unit/provider/package/yum_spec.rb +235 -1
  176. data/spec/unit/provider/service/systemd_spec.rb +10 -1
  177. data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
  178. data/spec/unit/puppet_pal_2pec.rb +0 -29
  179. data/spec/unit/reports/http_spec.rb +70 -52
  180. data/spec/unit/ssl/host_spec.rb +4 -2
  181. data/spec/unit/ssl/oids_spec.rb +1 -0
  182. data/spec/unit/ssl/state_machine_spec.rb +38 -6
  183. data/spec/unit/transaction/report_spec.rb +4 -0
  184. data/spec/unit/util/at_fork_spec.rb +2 -2
  185. data/spec/unit/util/package/version/debian_spec.rb +83 -0
  186. data/spec/unit/util/package/version/pip_spec.rb +464 -0
  187. data/spec/unit/util/package/version/range_spec.rb +154 -0
  188. data/spec/unit/util/package/version/rpm_spec.rb +121 -0
  189. data/spec/unit/util/pidlock_spec.rb +83 -47
  190. data/spec/unit/util/rpm_compare_spec.rb +196 -0
  191. data/spec/unit/util/windows/adsi_spec.rb +4 -4
  192. data/spec/unit/util/windows/sid_spec.rb +2 -2
  193. data/tasks/generate_cert_fixtures.rake +15 -1
  194. metadata +51 -6
  195. data/spec/integration/faces/plugin_spec.rb +0 -63
@@ -2,10 +2,33 @@ require 'puppet/transaction/report'
2
2
  require 'puppet/indirector/yaml'
3
3
 
4
4
  class Puppet::Transaction::Report::Yaml < Puppet::Indirector::Yaml
5
+ include Puppet::Util::SymbolicFileMode
6
+
5
7
  desc "Store last report as a flat file, serialized using YAML."
6
8
 
7
9
  # Force report to be saved there
8
10
  def path(name,ext='.yaml')
9
11
  Puppet[:lastrunreport]
10
12
  end
13
+
14
+ def save(request)
15
+ filename = path(request.key)
16
+ mode = Puppet.settings.setting(:lastrunreport).mode
17
+
18
+ unless valid_symbolic_mode?(mode)
19
+ raise Puppet::DevError, _("replace_file mode: %{mode} is invalid") % { mode: mode }
20
+ end
21
+
22
+ mode = symbolic_mode_to_int(normalize_symbolic_mode(mode))
23
+
24
+ FileUtils.mkdir_p(File.dirname(filename))
25
+
26
+ begin
27
+ Puppet::FileSystem.replace_file(filename, mode) do |fh|
28
+ fh.print YAML.dump(request.instance)
29
+ end
30
+ rescue TypeError => detail
31
+ Puppet.err _("Could not save %{indirection} %{request}: %{detail}") % { indirection: self.name, request: request.key, detail: detail }
32
+ end
33
+ end
11
34
  end
@@ -11,7 +11,8 @@ class Puppet::Indirector::Status::Rest < Puppet::Indirector::REST
11
11
 
12
12
  session = Puppet.lookup(:http_session)
13
13
  api = session.route_to(:puppet)
14
- api.get_status(request.key)
14
+ _, status = api.get_status(request.key)
15
+ status
15
16
  rescue Puppet::HTTP::ResponseError => e
16
17
  if e.response.code == 404
17
18
  return nil unless request.options[:fail_on_404]
@@ -70,68 +70,68 @@ module Manager
70
70
  # @dsl type
71
71
  # @api public
72
72
  def newtype(name, options = {}, &block)
73
- # Handle backward compatibility
74
- unless options.is_a?(Hash)
75
- #TRANSLATORS 'Puppet::Type.newtype' should not be translated
76
- Puppet.warning(_("Puppet::Type.newtype(%{name}) now expects a hash as the second argument, not %{argument}") %
77
- { name: name, argument: options.inspect})
78
- end
79
-
80
- # First make sure we don't have a method sitting around
81
- name = name.intern
82
- newmethod = "new#{name}"
73
+ @manager_lock.synchronize do
74
+ # Handle backward compatibility
75
+ unless options.is_a?(Hash)
76
+ #TRANSLATORS 'Puppet::Type.newtype' should not be translated
77
+ Puppet.warning(_("Puppet::Type.newtype(%{name}) now expects a hash as the second argument, not %{argument}") %
78
+ { name: name, argument: options.inspect})
79
+ end
83
80
 
84
- # Used for method manipulation.
85
- selfobj = singleton_class
81
+ # First make sure we don't have a method sitting around
82
+ name = name.intern
83
+ newmethod = "new#{name}"
86
84
 
87
- @types ||= {}
85
+ # Used for method manipulation.
86
+ selfobj = singleton_class
88
87
 
89
- if @types.include?(name)
90
- if self.respond_to?(newmethod)
91
- # Remove the old newmethod
92
- selfobj.send(:remove_method,newmethod)
88
+ if @types.include?(name)
89
+ if self.respond_to?(newmethod)
90
+ # Remove the old newmethod
91
+ selfobj.send(:remove_method,newmethod)
92
+ end
93
93
  end
94
- end
95
-
96
- # Then create the class.
97
94
 
98
- klass = genclass(
99
- name,
100
- :parent => Puppet::Type,
101
- :overwrite => true,
102
- :hash => @types,
103
- :attributes => options,
104
- &block
105
- )
106
-
107
- # Now define a "new<type>" method for convenience.
108
- if self.respond_to? newmethod
109
- # Refuse to overwrite existing methods like 'newparam' or 'newtype'.
110
- #TRANSLATORS 'new%{method}' will become a method name, do not translate this string
111
- Puppet.warning(_("'new%{method}' method already exists; skipping") % { method: name.to_s })
112
- else
113
- selfobj.send(:define_method, newmethod) do |*args|
114
- klass.new(*args)
95
+ # Then create the class.
96
+
97
+ klass = genclass(
98
+ name,
99
+ :parent => Puppet::Type,
100
+ :overwrite => true,
101
+ :hash => @types,
102
+ :attributes => options,
103
+ &block
104
+ )
105
+
106
+ # Now define a "new<type>" method for convenience.
107
+ if self.respond_to? newmethod
108
+ # Refuse to overwrite existing methods like 'newparam' or 'newtype'.
109
+ #TRANSLATORS 'new%{method}' will become a method name, do not translate this string
110
+ Puppet.warning(_("'new%{method}' method already exists; skipping") % { method: name.to_s })
111
+ else
112
+ selfobj.send(:define_method, newmethod) do |*args|
113
+ klass.new(*args)
114
+ end
115
115
  end
116
- end
117
116
 
118
- # If they've got all the necessary methods defined and they haven't
119
- # already added the property, then do so now.
120
- klass.ensurable if klass.ensurable? and ! klass.validproperty?(:ensure)
117
+ # If they've got all the necessary methods defined and they haven't
118
+ # already added the property, then do so now.
119
+ klass.ensurable if klass.ensurable? and ! klass.validproperty?(:ensure)
121
120
 
122
- # Now set up autoload any providers that might exist for this type.
121
+ # Now set up autoload any providers that might exist for this type.
123
122
 
124
- klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name}")
123
+ klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name}")
125
124
 
126
- # We have to load everything so that we can figure out the default provider.
127
- klass.providerloader.loadall(Puppet.lookup(:current_environment))
128
- klass.providify unless klass.providers.empty?
125
+ # We have to load everything so that we can figure out the default provider.
126
+ klass.providerloader.loadall(Puppet.lookup(:current_environment))
127
+ klass.providify unless klass.providers.empty?
129
128
 
130
- loc = block_given? ? block.source_location : nil
131
- uri = loc.nil? ? nil : URI("#{Puppet::Util.path_to_uri(loc[0])}?line=#{loc[1]}")
132
- Puppet::Pops::Loaders.register_runtime3_type(name, uri)
129
+ loc = block_given? ? block.source_location : nil
130
+ uri = loc.nil? ? nil : URI("#{Puppet::Util.path_to_uri(loc[0])}?line=#{loc[1]}")
131
+ Puppet::Pops::Loaders.register_runtime3_type(name, uri)
133
132
 
134
- klass
133
+ klass
134
+ end
135
135
  end
136
136
 
137
137
  # Removes an existing type.
@@ -151,47 +151,47 @@ module Manager
151
151
  # @return [Puppet::Type, nil] the type or nil if the type was not defined and could not be loaded
152
152
  #
153
153
  def type(name)
154
- # Avoid loading if name obviously is not a type name
155
- if name.to_s.include?(':')
156
- return nil
157
- end
154
+ @manager_lock.synchronize do
155
+ # Avoid loading if name obviously is not a type name
156
+ if name.to_s.include?(':')
157
+ return nil
158
+ end
158
159
 
159
- @types ||= {}
160
+ # We are overwhelmingly symbols here, which usually match, so it is worth
161
+ # having this special-case to return quickly. Like, 25K symbols vs. 300
162
+ # strings in this method. --daniel 2012-07-17
163
+ return @types[name] if @types.include? name
160
164
 
161
- # We are overwhelmingly symbols here, which usually match, so it is worth
162
- # having this special-case to return quickly. Like, 25K symbols vs. 300
163
- # strings in this method. --daniel 2012-07-17
164
- return @types[name] if @types.include? name
165
+ # Try mangling the name, if it is a string.
166
+ if name.is_a? String
167
+ name = name.downcase.intern
168
+ return @types[name] if @types.include? name
169
+ end
170
+ # Try loading the type.
171
+ if typeloader.load(name, Puppet.lookup(:current_environment))
172
+ #TRANSLATORS 'puppet/type/%{name}' should not be translated
173
+ Puppet.warning(_("Loaded puppet/type/%{name} but no class was created") % { name: name }) unless @types.include? name
174
+ elsif !Puppet[:always_retry_plugins]
175
+ # PUP-5482 - Only look for a type once if plugin retry is disabled
176
+ @types[name] = nil
177
+ end
165
178
 
166
- # Try mangling the name, if it is a string.
167
- if name.is_a? String
168
- name = name.downcase.intern
169
- return @types[name] if @types.include? name
170
- end
171
- # Try loading the type.
172
- if typeloader.load(name, Puppet.lookup(:current_environment))
173
- #TRANSLATORS 'puppet/type/%{name}' should not be translated
174
- Puppet.warning(_("Loaded puppet/type/%{name} but no class was created") % { name: name }) unless @types.include? name
175
- elsif !Puppet[:always_retry_plugins]
176
- # PUP-5482 - Only look for a type once if plugin retry is disabled
177
- @types[name] = nil
179
+ # ...and I guess that is that, eh.
180
+ return @types[name]
178
181
  end
179
-
180
- # ...and I guess that is that, eh.
181
- return @types[name]
182
182
  end
183
183
 
184
184
  # Creates a loader for Puppet types.
185
185
  # Defaults to an instance of {Puppet::Util::Autoload} if no other auto loader has been set.
186
186
  # @return [Puppet::Util::Autoload] the loader to use.
187
187
  # @api private
188
- def typeloader
189
- unless defined?(@typeloader)
190
- @typeloader = Puppet::Util::Autoload.new(self, "puppet/type")
191
- end
188
+ def typeloader
189
+ unless defined?(@typeloader)
190
+ @typeloader = Puppet::Util::Autoload.new(self, "puppet/type")
191
+ end
192
192
 
193
- @typeloader
194
- end
193
+ @typeloader
194
+ end
195
195
  end
196
196
  end
197
197
 
@@ -26,6 +26,11 @@ class Puppet::Network::HTTP::BasePool
26
26
  socket = buffered_io.io
27
27
  return unless socket
28
28
 
29
- Puppet.debug("Using #{socket.ssl_version} with cipher #{socket.cipher.first}")
29
+ cipher = if Puppet::Util::Platform.jruby?
30
+ socket.cipher
31
+ else
32
+ socket.cipher.first
33
+ end
34
+ Puppet.debug("Using #{socket.ssl_version} with cipher #{cipher}")
30
35
  end
31
36
  end
@@ -9,11 +9,9 @@
9
9
  # @api private
10
10
  #
11
11
  class Puppet::Network::HTTP::Pool < Puppet::Network::HTTP::BasePool
12
- FIFTEEN_SECONDS = 15
12
+ attr_reader :factory, :keepalive_timeout
13
13
 
14
- attr_reader :factory
15
-
16
- def initialize(keepalive_timeout = FIFTEEN_SECONDS)
14
+ def initialize(keepalive_timeout)
17
15
  @pool = {}
18
16
  @factory = Puppet::Network::HTTP::Factory.new
19
17
  @keepalive_timeout = keepalive_timeout
@@ -19,6 +19,7 @@ module Puppet::Network::HttpPool
19
19
  end
20
20
  def self.http_client_class=(klass)
21
21
  @http_client_class = klass
22
+ Puppet.runtime['http'] = Puppet::HTTP::ExternalClient.new(klass)
22
23
  end
23
24
 
24
25
  # Retrieve a connection for the given host and port.
@@ -162,6 +162,10 @@ class Puppet::Node::Environment
162
162
  # @api private
163
163
  attr_accessor :loaders
164
164
 
165
+ # Lock for compilation that needs exclusive access to the environment
166
+ # @api private
167
+ attr_reader :lock
168
+
165
169
  # Checks to make sure that this environment did not have a manifest set in
166
170
  # its original environment.conf if Puppet is configured with
167
171
  # +disable_per_environment_manifest+ set true. If it did, the environment's
@@ -293,7 +297,13 @@ class Puppet::Node::Environment
293
297
  def modules
294
298
  if @modules.nil?
295
299
  module_references = []
296
- seen_modules = {}
300
+ project = Puppet.lookup(:bolt_project) { nil }
301
+ seen_modules = if project
302
+ module_references << project.to_h
303
+ { project.name => true }
304
+ else
305
+ {}
306
+ end
297
307
  modulepath.each do |path|
298
308
  Dir.entries(path).each do |name|
299
309
  next unless Puppet::Module.is_module_directory?(name, path)
@@ -422,37 +422,9 @@ module Pal
422
422
  # TRANSLATORS, the string "For puppet PAL" is not user facing
423
423
  Puppet.override({:current_environment => apply_environment}, "For puppet PAL") do
424
424
  begin
425
- # support the following features when evaluating puppet code
426
- # * $facts with facts from host running the script
427
- # * $settings with 'settings::*' namespace populated, and '$settings::all_local' hash
428
- # * $trusted as setup when using puppet apply
429
- # * an environment
430
- #
431
-
432
- # fixup trusted information
433
425
  node.sanitize()
434
-
435
426
  compiler = create_internal_compiler(internal_compiler_class, node)
436
- # compiler = Puppet::Parser::ScriptCompiler.new(node.environment, node.name)
437
- topscope = compiler.topscope
438
-
439
- # When scripting the trusted data are always local, but set them anyway
440
- # When compiling for a catalog, the catalog compiler does this
441
- unless internal_compiler_class == :catalog
442
- topscope.set_trusted(node.trusted_data)
443
-
444
- # Server facts are always about the local node's version etc.
445
- topscope.set_server_facts(node.server_facts)
446
-
447
- # Set $facts for the node running the script
448
- facts_hash = node.facts.nil? ? {} : node.facts.values
449
- topscope.set_facts(facts_hash)
450
-
451
- # create the $settings:: variables
452
- topscope.merge_settings(node.environment.name, false)
453
- end
454
-
455
- add_variables(topscope, pal_variables)
427
+ add_variables(compiler.topscope, pal_variables)
456
428
 
457
429
  case internal_compiler_class
458
430
  when :script
@@ -777,13 +777,7 @@ class Puppet::Parser::Compiler
777
777
  SETTINGS = 'settings'.freeze
778
778
 
779
779
  def create_settings_scope
780
- resource_types = environment.known_resource_types
781
- settings_type = resource_types.hostclass(SETTINGS)
782
- if settings_type.nil?
783
- settings_type = Puppet::Resource::Type.new(:hostclass, SETTINGS)
784
- resource_types.add(settings_type)
785
- end
786
-
780
+ settings_type = create_settings_type
787
781
  settings_resource = Puppet::Parser::Resource.new('class', SETTINGS, :scope => @topscope)
788
782
 
789
783
  @catalog.add_resource(settings_resource)
@@ -794,6 +788,19 @@ class Puppet::Parser::Compiler
794
788
  scope.merge_settings(environment.name)
795
789
  end
796
790
 
791
+ def create_settings_type
792
+ environment.lock.synchronize do
793
+ resource_types = environment.known_resource_types
794
+ settings_type = resource_types.hostclass(SETTINGS)
795
+ if settings_type.nil?
796
+ settings_type = Puppet::Resource::Type.new(:hostclass, SETTINGS)
797
+ resource_types.add(settings_type)
798
+ end
799
+
800
+ settings_type
801
+ end
802
+ end
803
+
797
804
  # Return an array of all of the unevaluated resources. These will be definitions,
798
805
  # which need to get evaluated into native resources.
799
806
  def unevaluated_resources
@@ -1,6 +1,7 @@
1
1
  require 'puppet/util/autoload'
2
2
  require 'puppet/parser/scope'
3
3
  require 'puppet/pops/adaptable'
4
+ require 'puppet/concurrent/lock'
4
5
 
5
6
  # A module for managing parser functions. Each specified function
6
7
  # is added to a central module that then gets included into the Scope
@@ -78,28 +79,32 @@ module Puppet::Parser::Functions
78
79
  attr_accessor :module
79
80
  end
80
81
 
82
+ @environment_module_lock = Puppet::Concurrent::Lock.new
83
+
81
84
  # Get the module that functions are mixed into corresponding to an
82
85
  # environment
83
86
  #
84
87
  # @api private
85
88
  def self.environment_module(env)
86
- AnonymousModuleAdapter.adapt(env) do |a|
87
- a.module ||= Module.new do
88
- @metadata = {}
89
+ @environment_module_lock.synchronize do
90
+ AnonymousModuleAdapter.adapt(env) do |a|
91
+ a.module ||= Module.new do
92
+ @metadata = {}
89
93
 
90
- def self.all_function_info
91
- @metadata
92
- end
94
+ def self.all_function_info
95
+ @metadata
96
+ end
93
97
 
94
- def self.get_function_info(name)
95
- @metadata[name]
96
- end
98
+ def self.get_function_info(name)
99
+ @metadata[name]
100
+ end
97
101
 
98
- def self.add_function_info(name, info)
99
- @metadata[name] = info
102
+ def self.add_function_info(name, info)
103
+ @metadata[name] = info
104
+ end
100
105
  end
101
- end
102
- end.module
106
+ end.module
107
+ end
103
108
  end
104
109
 
105
110
  # Create a new Puppet DSL function.
@@ -19,12 +19,14 @@ class Loaders
19
19
  attr_reader :environment
20
20
 
21
21
  def self.new(environment, for_agent = false)
22
- obj = environment.loaders
23
- if obj.nil?
24
- obj = self.allocate
25
- obj.send(:initialize, environment, for_agent)
22
+ environment.lock.synchronize do
23
+ obj = environment.loaders
24
+ if obj.nil?
25
+ obj = self.allocate
26
+ obj.send(:initialize, environment, for_agent)
27
+ end
28
+ obj
26
29
  end
27
- obj
28
30
  end
29
31
 
30
32
  def initialize(environment, for_agent)