puppet 6.14.0 → 6.15.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -15
- data/ext/windows/service/daemon.rb +3 -3
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -10
- data/lib/puppet/application/agent.rb +2 -1
- data/lib/puppet/application/filebucket.rb +5 -14
- data/lib/puppet/application/ssl.rb +2 -2
- data/lib/puppet/configurer.rb +7 -3
- data/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/lib/puppet/defaults.rb +22 -2
- data/lib/puppet/environments.rb +4 -5
- data/lib/puppet/face/plugin.rb +1 -1
- data/lib/puppet/file_system/file_impl.rb +13 -9
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/functions/call.rb +1 -1
- data/lib/puppet/functions/reduce.rb +2 -4
- data/lib/puppet/http.rb +2 -0
- data/lib/puppet/http/client.rb +191 -52
- data/lib/puppet/http/external_client.rb +96 -0
- data/lib/puppet/http/redirector.rb +34 -0
- data/lib/puppet/http/resolver.rb +46 -3
- data/lib/puppet/http/resolver/server_list.rb +75 -15
- data/lib/puppet/http/resolver/settings.rb +22 -2
- data/lib/puppet/http/resolver/srv.rb +28 -2
- data/lib/puppet/http/response.rb +63 -1
- data/lib/puppet/http/retry_after_handler.rb +39 -0
- data/lib/puppet/http/service.rb +67 -1
- data/lib/puppet/http/service/ca.rb +71 -9
- data/lib/puppet/http/service/compiler.rb +213 -11
- data/lib/puppet/http/service/file_server.rb +105 -4
- data/lib/puppet/http/service/report.rb +36 -3
- data/lib/puppet/http/session.rb +59 -8
- data/lib/puppet/indirector/catalog/rest.rb +2 -1
- data/lib/puppet/indirector/facts/rest.rb +2 -1
- data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +4 -2
- data/lib/puppet/indirector/node/rest.rb +2 -1
- data/lib/puppet/indirector/report/yaml.rb +23 -0
- data/lib/puppet/indirector/status/rest.rb +2 -1
- data/lib/puppet/metatype/manager.rb +80 -80
- data/lib/puppet/network/http/base_pool.rb +6 -1
- data/lib/puppet/network/http/pool.rb +2 -4
- data/lib/puppet/network/http_pool.rb +1 -0
- data/lib/puppet/node/environment.rb +11 -1
- data/lib/puppet/pal/pal_impl.rb +1 -29
- data/lib/puppet/parser/compiler.rb +14 -7
- data/lib/puppet/parser/functions.rb +18 -13
- data/lib/puppet/pops/loaders.rb +7 -5
- data/lib/puppet/provider/group/windows_adsi.rb +3 -3
- data/lib/puppet/provider/package/apt.rb +61 -1
- data/lib/puppet/provider/package/dnfmodule.rb +39 -12
- data/lib/puppet/provider/package/gem.rb +41 -7
- data/lib/puppet/provider/package/pacman.rb +2 -5
- data/lib/puppet/provider/package/pip.rb +105 -33
- data/lib/puppet/provider/package/pip3.rb +0 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgng.rb +16 -4
- data/lib/puppet/provider/package/puppet_gem.rb +6 -2
- data/lib/puppet/provider/package/rpm.rb +6 -213
- data/lib/puppet/provider/package/yum.rb +92 -19
- data/lib/puppet/provider/service/systemd.rb +2 -1
- data/lib/puppet/reports/http.rb +13 -11
- data/lib/puppet/resource/type_collection.rb +20 -16
- data/lib/puppet/ssl.rb +1 -0
- data/lib/puppet/ssl/host.rb +4 -4
- data/lib/puppet/ssl/oids.rb +1 -0
- data/lib/puppet/ssl/state_machine.rb +50 -33
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +6 -1
- data/lib/puppet/type/file/source.rb +4 -2
- data/lib/puppet/type/package.rb +25 -2
- data/lib/puppet/type/user.rb +0 -19
- data/lib/puppet/util/at_fork.rb +1 -1
- data/lib/puppet/util/autoload.rb +3 -0
- data/lib/puppet/util/instance_loader.rb +14 -10
- data/lib/puppet/util/package/version/debian.rb +175 -0
- data/lib/puppet/util/package/version/gem.rb +15 -0
- data/lib/puppet/util/package/version/pip.rb +167 -0
- data/lib/puppet/util/package/version/range.rb +50 -0
- data/lib/puppet/util/package/version/range/gt.rb +14 -0
- data/lib/puppet/util/package/version/range/gt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/lt.rb +14 -0
- data/lib/puppet/util/package/version/range/lt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/min_max.rb +21 -0
- data/lib/puppet/util/package/version/range/simple.rb +11 -0
- data/lib/puppet/util/package/version/rpm.rb +73 -0
- data/lib/puppet/util/pidlock.rb +13 -7
- data/lib/puppet/util/platform.rb +5 -0
- data/lib/puppet/util/rpm_compare.rb +193 -0
- data/lib/puppet/util/windows/adsi.rb +2 -2
- data/lib/puppet/util/windows/process.rb +15 -14
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/util/windows/sid.rb +3 -3
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +207 -201
- data/man/man5/puppet.conf.5 +11 -3
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -0
- data/spec/fixtures/ssl/unknown-ca-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-ca.pem +59 -0
- data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list-enabled.txt} +2 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
- data/spec/integration/application/agent_spec.rb +329 -0
- data/spec/integration/application/apply_spec.rb +132 -3
- data/spec/integration/application/filebucket_spec.rb +190 -0
- data/spec/integration/application/plugin_spec.rb +50 -0
- data/spec/integration/http/client_spec.rb +34 -40
- data/spec/integration/indirector/report/yaml.rb +83 -0
- data/spec/integration/module_tool/forge_spec.rb +2 -15
- data/spec/integration/network/http_pool_spec.rb +11 -19
- data/spec/integration/node/environment_spec.rb +15 -0
- data/spec/integration/util/windows/adsi_spec.rb +1 -1
- data/spec/lib/puppet/test_ca.rb +2 -2
- data/spec/lib/puppet_spec/https.rb +10 -7
- data/spec/lib/puppet_spec/puppetserver.rb +119 -0
- data/spec/shared_contexts/https.rb +29 -0
- data/spec/unit/agent_spec.rb +33 -25
- data/spec/unit/application/agent_spec.rb +5 -1
- data/spec/unit/application/device_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +22 -2
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +24 -1
- data/spec/unit/environments_spec.rb +8 -0
- data/spec/unit/file_system_spec.rb +10 -0
- data/spec/unit/http/client_spec.rb +105 -46
- data/spec/unit/http/external_client_spec.rb +201 -0
- data/spec/unit/http/resolver_spec.rb +20 -0
- data/spec/unit/http/service/ca_spec.rb +25 -2
- data/spec/unit/http/service/compiler_spec.rb +184 -6
- data/spec/unit/http/service/file_server_spec.rb +35 -3
- data/spec/unit/http/service/report_spec.rb +3 -1
- data/spec/unit/http/service_spec.rb +3 -3
- data/spec/unit/http/session_spec.rb +56 -7
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
- data/spec/unit/network/http/pool_spec.rb +3 -3
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
- data/spec/unit/provider/package/apt_spec.rb +30 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +33 -14
- data/spec/unit/provider/package/gem_spec.rb +40 -0
- data/spec/unit/provider/package/pacman_spec.rb +6 -21
- data/spec/unit/provider/package/pip_spec.rb +26 -3
- data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
- data/spec/unit/provider/package/pkgng_spec.rb +38 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +8 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -212
- data/spec/unit/provider/package/yum_spec.rb +235 -1
- data/spec/unit/provider/service/systemd_spec.rb +10 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
- data/spec/unit/puppet_pal_2pec.rb +0 -29
- data/spec/unit/reports/http_spec.rb +70 -52
- data/spec/unit/ssl/host_spec.rb +4 -2
- data/spec/unit/ssl/oids_spec.rb +1 -0
- data/spec/unit/ssl/state_machine_spec.rb +38 -6
- data/spec/unit/transaction/report_spec.rb +4 -0
- data/spec/unit/util/at_fork_spec.rb +2 -2
- data/spec/unit/util/package/version/debian_spec.rb +83 -0
- data/spec/unit/util/package/version/pip_spec.rb +464 -0
- data/spec/unit/util/package/version/range_spec.rb +154 -0
- data/spec/unit/util/package/version/rpm_spec.rb +121 -0
- data/spec/unit/util/pidlock_spec.rb +83 -47
- data/spec/unit/util/rpm_compare_spec.rb +196 -0
- data/spec/unit/util/windows/adsi_spec.rb +4 -4
- data/spec/unit/util/windows/sid_spec.rb +2 -2
- data/tasks/generate_cert_fixtures.rake +15 -1
- metadata +51 -6
- 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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
85
|
-
|
81
|
+
# First make sure we don't have a method sitting around
|
82
|
+
name = name.intern
|
83
|
+
newmethod = "new#{name}"
|
86
84
|
|
87
|
-
|
85
|
+
# Used for method manipulation.
|
86
|
+
selfobj = singleton_class
|
88
87
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
121
|
+
# Now set up autoload any providers that might exist for this type.
|
123
122
|
|
124
|
-
|
123
|
+
klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name}")
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
-
|
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
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
-
|
167
|
-
|
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
|
-
|
190
|
-
|
191
|
-
|
188
|
+
def typeloader
|
189
|
+
unless defined?(@typeloader)
|
190
|
+
@typeloader = Puppet::Util::Autoload.new(self, "puppet/type")
|
191
|
+
end
|
192
192
|
|
193
|
-
|
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
|
-
|
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
|
-
|
12
|
+
attr_reader :factory, :keepalive_timeout
|
13
13
|
|
14
|
-
|
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
|
@@ -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
|
-
|
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)
|
data/lib/puppet/pal/pal_impl.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
+
@environment_module_lock.synchronize do
|
90
|
+
AnonymousModuleAdapter.adapt(env) do |a|
|
91
|
+
a.module ||= Module.new do
|
92
|
+
@metadata = {}
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
94
|
+
def self.all_function_info
|
95
|
+
@metadata
|
96
|
+
end
|
93
97
|
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
def self.get_function_info(name)
|
99
|
+
@metadata[name]
|
100
|
+
end
|
97
101
|
|
98
|
-
|
99
|
-
|
102
|
+
def self.add_function_info(name, info)
|
103
|
+
@metadata[name] = info
|
104
|
+
end
|
100
105
|
end
|
101
|
-
end
|
102
|
-
end
|
106
|
+
end.module
|
107
|
+
end
|
103
108
|
end
|
104
109
|
|
105
110
|
# Create a new Puppet DSL function.
|
data/lib/puppet/pops/loaders.rb
CHANGED
@@ -19,12 +19,14 @@ class Loaders
|
|
19
19
|
attr_reader :environment
|
20
20
|
|
21
21
|
def self.new(environment, for_agent = false)
|
22
|
-
|
23
|
-
|
24
|
-
obj
|
25
|
-
|
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)
|