puppet 7.22.0 → 7.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +57 -68
- data/lib/puppet/application/face_base.rb +2 -1
- data/lib/puppet/defaults.rb +13 -0
- data/lib/puppet/environments.rb +9 -0
- data/lib/puppet/functions/each.rb +11 -13
- data/lib/puppet/functions/filter.rb +5 -13
- data/lib/puppet/functions/map.rb +7 -8
- data/lib/puppet/interface/action.rb +3 -3
- data/lib/puppet/interface/documentation.rb +2 -2
- data/lib/puppet/interface/option.rb +3 -4
- data/lib/puppet/module/plan.rb +1 -1
- data/lib/puppet/module/task.rb +1 -1
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +5 -4
- data/lib/puppet/node/environment.rb +38 -0
- data/lib/puppet/node.rb +2 -2
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -1
- data/lib/puppet/pops/functions/function.rb +1 -3
- data/lib/puppet/pops/loader/dependency_loader.rb +1 -4
- data/lib/puppet/pops/loader/loader_paths.rb +1 -3
- data/lib/puppet/pops/loader/module_loaders.rb +1 -1
- data/lib/puppet/pops/loaders.rb +6 -2
- data/lib/puppet/pops/lookup/context.rb +3 -4
- data/lib/puppet/pops/lookup/hiera_config.rb +1 -1
- data/lib/puppet/resource.rb +4 -0
- data/lib/puppet/settings/base_setting.rb +3 -2
- data/lib/puppet/settings.rb +0 -1
- data/lib/puppet/type/file/ctime.rb +1 -1
- data/lib/puppet/type/file/mtime.rb +1 -1
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +13 -2
- 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-lookup.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.8 +2 -2
- data/spec/fixtures/integration/application/module/environments/direnv/modules/nginx/README +3 -0
- data/spec/fixtures/integration/application/module/environments/direnv/modules/nginx/manifests/init.pp +17 -0
- data/spec/fixtures/integration/application/module/environments/direnv/modules/nginx/metadata.json +20 -0
- data/spec/integration/application/module_spec.rb +141 -0
- data/spec/unit/environments_spec.rb +9 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +2 -0
- data/spec/unit/node/environment_spec.rb +41 -0
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +9 -0
- data/spec/unit/type/file/ctime_spec.rb +1 -1
- data/spec/unit/type/file/mtime_spec.rb +1 -1
- metadata +9 -3
|
@@ -86,4 +86,145 @@ describe 'puppet module', unless: Puppet::Util::Platform.jruby? do
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
+
|
|
90
|
+
context 'install' do
|
|
91
|
+
it 'lists a module in a non-default directory environment' do
|
|
92
|
+
Puppet.initialize_settings(['-E', 'direnv'])
|
|
93
|
+
Puppet[:color] = false
|
|
94
|
+
Puppet[:environmentpath] = File.join(my_fixture_dir, 'environments')
|
|
95
|
+
|
|
96
|
+
expect {
|
|
97
|
+
app.command_line.args = ['list']
|
|
98
|
+
app.run
|
|
99
|
+
}.to exit_with(0)
|
|
100
|
+
.and output(Regexp.new("└── pmtacceptance-nginx".encode(Encoding.default_external), Regexp::MULTILINE)).to_stdout
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'changes' do
|
|
105
|
+
let(:tmp) { tmpdir('module_changes') }
|
|
106
|
+
|
|
107
|
+
before :each do
|
|
108
|
+
Puppet.initialize_settings(['-E', 'direnv'])
|
|
109
|
+
Puppet[:color] = false
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def use_local_fixture
|
|
113
|
+
Puppet[:environmentpath] = File.join(my_fixture_dir, 'environments')
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def create_working_copy
|
|
117
|
+
Puppet[:environmentpath] = File.join(tmp, 'environments')
|
|
118
|
+
FileUtils.cp_r(File.join(my_fixture_dir, 'environments'), tmp)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'reports an error when the install path is invalid' do
|
|
122
|
+
use_local_fixture
|
|
123
|
+
|
|
124
|
+
pattern = Regexp.new([
|
|
125
|
+
%Q{.*Error: Could not find a valid module at "#{tmp}/nginx".*},
|
|
126
|
+
%Q{.*Error: Try 'puppet help module changes' for usage.*},
|
|
127
|
+
].join("\n"), Regexp::MULTILINE)
|
|
128
|
+
|
|
129
|
+
expect {
|
|
130
|
+
app.command_line.args = ['changes', File.join(tmp, 'nginx')]
|
|
131
|
+
app.run
|
|
132
|
+
}.to exit_with(1)
|
|
133
|
+
.and output(pattern).to_stderr
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'reports when checksums are missing from metadata.json' do
|
|
137
|
+
create_working_copy
|
|
138
|
+
|
|
139
|
+
# overwrite checksums in metadata.json
|
|
140
|
+
nginx_dir = File.join(tmp, 'environments', 'direnv', 'modules', 'nginx')
|
|
141
|
+
File.write(File.join(nginx_dir, 'metadata.json'), <<~END)
|
|
142
|
+
{
|
|
143
|
+
"name": "pmtacceptance/nginx",
|
|
144
|
+
"version": "0.0.1"
|
|
145
|
+
}
|
|
146
|
+
END
|
|
147
|
+
|
|
148
|
+
pattern = Regexp.new([
|
|
149
|
+
%Q{.*Error: No file containing checksums found.*},
|
|
150
|
+
%Q{.*Error: Try 'puppet help module changes' for usage.*},
|
|
151
|
+
].join("\n"), Regexp::MULTILINE)
|
|
152
|
+
|
|
153
|
+
expect {
|
|
154
|
+
app.command_line.args = ['changes', nginx_dir]
|
|
155
|
+
app.run
|
|
156
|
+
}.to exit_with(1)
|
|
157
|
+
.and output(pattern).to_stderr
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'reports module not found when metadata.json is missing' do
|
|
161
|
+
create_working_copy
|
|
162
|
+
|
|
163
|
+
# overwrite checksums in metadata.json
|
|
164
|
+
nginx_dir = File.join(tmp, 'environments', 'direnv', 'modules', 'nginx')
|
|
165
|
+
File.unlink(File.join(nginx_dir, 'metadata.json'))
|
|
166
|
+
|
|
167
|
+
pattern = Regexp.new([
|
|
168
|
+
%Q{.*Error: Could not find a valid module at.*},
|
|
169
|
+
%Q{.*Error: Try 'puppet help module changes' for usage.*},
|
|
170
|
+
].join("\n"), Regexp::MULTILINE)
|
|
171
|
+
|
|
172
|
+
expect {
|
|
173
|
+
app.command_line.args = ['changes', nginx_dir]
|
|
174
|
+
app.run
|
|
175
|
+
}.to exit_with(1)
|
|
176
|
+
.and output(pattern).to_stderr
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it 'reports when a file is modified' do
|
|
180
|
+
create_working_copy
|
|
181
|
+
|
|
182
|
+
# overwrite README so checksum doesn't match
|
|
183
|
+
nginx_dir = File.join(tmp, 'environments', 'direnv', 'modules', 'nginx')
|
|
184
|
+
File.write(File.join(nginx_dir, 'README'), '')
|
|
185
|
+
|
|
186
|
+
pattern = Regexp.new([
|
|
187
|
+
%Q{.*Warning: 1 files modified.*},
|
|
188
|
+
].join("\n"), Regexp::MULTILINE)
|
|
189
|
+
|
|
190
|
+
expect {
|
|
191
|
+
app.command_line.args = ['changes', nginx_dir]
|
|
192
|
+
app.run
|
|
193
|
+
}.to exit_with(0)
|
|
194
|
+
.and output(%r{README}).to_stdout
|
|
195
|
+
.and output(pattern).to_stderr
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'reports when a file is missing' do
|
|
199
|
+
create_working_copy
|
|
200
|
+
|
|
201
|
+
# delete README so checksum doesn't match
|
|
202
|
+
nginx_dir = File.join(tmp, 'environments', 'direnv', 'modules', 'nginx')
|
|
203
|
+
File.unlink(File.join(nginx_dir, 'README'))
|
|
204
|
+
|
|
205
|
+
# odd that it says modified
|
|
206
|
+
pattern = Regexp.new([
|
|
207
|
+
%Q{.*Warning: 1 files modified.*},
|
|
208
|
+
].join("\n"), Regexp::MULTILINE)
|
|
209
|
+
|
|
210
|
+
expect {
|
|
211
|
+
app.command_line.args = ['changes', nginx_dir]
|
|
212
|
+
app.run
|
|
213
|
+
}.to exit_with(0)
|
|
214
|
+
.and output(%r{README}).to_stdout
|
|
215
|
+
.and output(pattern).to_stderr
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'reports when there are no changes' do
|
|
219
|
+
use_local_fixture
|
|
220
|
+
|
|
221
|
+
nginx_dir = File.join(Puppet[:environmentpath], 'direnv', 'modules', 'nginx')
|
|
222
|
+
|
|
223
|
+
expect {
|
|
224
|
+
app.command_line.args = ['changes', nginx_dir]
|
|
225
|
+
app.run
|
|
226
|
+
}.to exit_with(0)
|
|
227
|
+
.and output(/No modified files/).to_stdout
|
|
228
|
+
end
|
|
229
|
+
end
|
|
89
230
|
end
|
|
@@ -115,6 +115,15 @@ describe Puppet::Environments do
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
+
it "sets the environment's configured and resolved paths set when symlinked" do
|
|
119
|
+
loader_from(:filesystem => [directory_tree],
|
|
120
|
+
:directory => directory_tree.children.first) do |loader|
|
|
121
|
+
env = loader.get("symlinked_environment")
|
|
122
|
+
expect(env.resolved_path).to eq("#{FS.path_string(directory_tree)}/versioned_env")
|
|
123
|
+
expect(env.configured_path).to eq("#{FS.path_string(directory_tree)}/envdir/symlinked_environment")
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
118
127
|
it "ignores symlinked environments when `:versioned_environment_dirs` is false" do
|
|
119
128
|
Puppet[:versioned_environment_dirs] = false
|
|
120
129
|
loader_from(:filesystem => [directory_tree],
|
|
@@ -182,6 +182,7 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
|
182
182
|
indirection.save(data, "my data")
|
|
183
183
|
request = a_request_that_finds(data, :accept_header => "application/json, text/pson")
|
|
184
184
|
allow(data).to receive(:to_json).and_raise(Puppet::Network::FormatHandler::FormatError, 'Could not render to Puppet::Network::Format[json]: source sequence is illegal/malformed utf-8')
|
|
185
|
+
expect(Puppet).to receive(:warning).with(/Failed to serialize Puppet::IndirectorTesting for 'my data': Could not render to Puppet::Network::Format\[json\]/)
|
|
185
186
|
|
|
186
187
|
handler.call(request, response)
|
|
187
188
|
|
|
@@ -228,6 +229,7 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
|
228
229
|
indirection.save(data, "my data")
|
|
229
230
|
request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "application/json, text/pson")
|
|
230
231
|
allow(data).to receive(:to_json).and_raise(Puppet::Network::FormatHandler::FormatError, 'Could not render to Puppet::Network::Format[json]: source sequence is illegal/malformed utf-8')
|
|
232
|
+
expect(Puppet).to receive(:warning).with(/Failed to serialize Puppet::IndirectorTesting for 'my': Could not render_multiple to Puppet::Network::Format\[json\]/)
|
|
231
233
|
|
|
232
234
|
handler.call(request, response)
|
|
233
235
|
|
|
@@ -40,6 +40,47 @@ describe Puppet::Node::Environment do
|
|
|
40
40
|
expect(e.inspect).to match(%r{<Puppet::Node::Environment:\w* @name="test" @manifest="#{File.expand_path('/manifests/path')}" @modulepath="#{File.expand_path('/modules/path')}:#{File.expand_path('/other/modules')}" >})
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
describe "externalizing filepaths" do
|
|
44
|
+
before(:each) do
|
|
45
|
+
env.resolved_path = "/opt/puppetlabs/envs/prod_123"
|
|
46
|
+
env.configured_path = "/etc/puppetlabs/envs/prod"
|
|
47
|
+
|
|
48
|
+
@vendored_manifest = "/opt/puppetlabs/vendored/modules/foo/manifests/init.pp"
|
|
49
|
+
@production_manifest = "/opt/puppetlabs/envs/prod_123/modules/foo/manifests/init.pp"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "leaves paths alone if they do not match the resolved path" do
|
|
53
|
+
expect(env.externalize_path(@vendored_manifest)).to eq(@vendored_manifest)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "leaves paths alone if resolved or configured paths are not set" do
|
|
57
|
+
env.resolved_path = nil
|
|
58
|
+
env.configured_path = nil
|
|
59
|
+
expect(env.externalize_path(@production_manifest)).to eq(@production_manifest)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "replaces resolved paths with configured paths" do
|
|
63
|
+
externalized_path = env.externalize_path(@production_manifest)
|
|
64
|
+
expect(externalized_path).to eq("/etc/puppetlabs/envs/prod/modules/foo/manifests/init.pp")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "handles nil" do
|
|
68
|
+
externalized_path = env.externalize_path(nil)
|
|
69
|
+
expect(externalized_path).to eq(nil)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "appropriately handles mismatched trailing slashes" do
|
|
73
|
+
env.resolved_path = "/opt/puppetlabs/envs/prod_123/"
|
|
74
|
+
externalized_path = env.externalize_path(@production_manifest)
|
|
75
|
+
expect(externalized_path).to eq("/etc/puppetlabs/envs/prod/modules/foo/manifests/init.pp")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "can be disabled with the `report_configured_environmentpath` setting" do
|
|
79
|
+
Puppet[:report_configured_environmentpath] = false
|
|
80
|
+
expect(env.externalize_path(@production_manifest)).to eq(@production_manifest)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
43
84
|
describe "equality" do
|
|
44
85
|
it "works as a hash key" do
|
|
45
86
|
base = Puppet::Node::Environment.create(:first, ["modules"], "manifests")
|
|
@@ -80,7 +80,7 @@ describe "the fqdn_rand function" do
|
|
|
80
80
|
extra = args[:extra_identifier] || []
|
|
81
81
|
|
|
82
82
|
scope = create_test_scope_for_node('localhost')
|
|
83
|
-
scope.
|
|
83
|
+
scope.set_facts({ 'networking' => { 'fqdn' => host }})
|
|
84
84
|
|
|
85
85
|
scope.function_fqdn_rand([max] + extra)
|
|
86
86
|
end
|
|
@@ -108,6 +108,15 @@ describe Puppet::Parser::Resource do
|
|
|
108
108
|
}.to raise_error(ArgumentError, /Resources require a hash as last argument/)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
it "should attempt to externalize filepaths via the environment" do
|
|
112
|
+
environment = Puppet::Node::Environment.create(:testing, [])
|
|
113
|
+
expect(environment).to receive(:externalize_path).at_least(:once).and_return("foo")
|
|
114
|
+
Puppet[:code] = "notify { 'hello': }"
|
|
115
|
+
catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new 'anyone', environment: environment)
|
|
116
|
+
notify = catalog.resource('Notify[hello]')
|
|
117
|
+
expect(notify.file).to eq("foo")
|
|
118
|
+
end
|
|
119
|
+
|
|
111
120
|
it "should set the reference correctly" do
|
|
112
121
|
res = Puppet::Parser::Resource.new("resource", "testing", @arguments)
|
|
113
122
|
expect(res.ref).to eq("Resource[testing]")
|
|
@@ -15,7 +15,7 @@ describe Puppet::Type.type(:file).attrclass(:ctime) do
|
|
|
15
15
|
@resource[:audit] = [:ctime]
|
|
16
16
|
|
|
17
17
|
# this .to_resource audit behavior is magical :-(
|
|
18
|
-
expect(@resource.to_resource[:ctime]).to eq(Puppet::FileSystem.stat(@filename).ctime)
|
|
18
|
+
expect(@resource.to_resource[:ctime]).to eq(Puppet::FileSystem.stat(@filename).ctime.to_s)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should return absent if auditing an absent file" do
|
|
@@ -15,7 +15,7 @@ describe Puppet::Type.type(:file).attrclass(:mtime) do
|
|
|
15
15
|
@resource[:audit] = [:mtime]
|
|
16
16
|
|
|
17
17
|
# this .to_resource audit behavior is magical :-(
|
|
18
|
-
expect(@resource.to_resource[:mtime]).to eq(Puppet::FileSystem.stat(@filename).mtime)
|
|
18
|
+
expect(@resource.to_resource[:mtime]).to eq(Puppet::FileSystem.stat(@filename).mtime.to_s)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should return absent if auditing an absent file" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puppet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppet Labs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: facter
|
|
@@ -1295,6 +1295,9 @@ files:
|
|
|
1295
1295
|
- spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb
|
|
1296
1296
|
- spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/provider/applytest/applytest.rb
|
|
1297
1297
|
- spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/type/applytest.rb
|
|
1298
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/README
|
|
1299
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/manifests/init.pp
|
|
1300
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/metadata.json
|
|
1298
1301
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile
|
|
1299
1302
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile
|
|
1300
1303
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb
|
|
@@ -2544,7 +2547,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
2544
2547
|
- !ruby/object:Gem::Version
|
|
2545
2548
|
version: 1.3.1
|
|
2546
2549
|
requirements: []
|
|
2547
|
-
rubygems_version: 3.
|
|
2550
|
+
rubygems_version: 3.1.6
|
|
2548
2551
|
signing_key:
|
|
2549
2552
|
specification_version: 4
|
|
2550
2553
|
summary: Puppet, an automated configuration management tool
|
|
@@ -2555,6 +2558,9 @@ test_files:
|
|
|
2555
2558
|
- spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb
|
|
2556
2559
|
- spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/provider/applytest/applytest.rb
|
|
2557
2560
|
- spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/type/applytest.rb
|
|
2561
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/README
|
|
2562
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/manifests/init.pp
|
|
2563
|
+
- spec/fixtures/integration/application/module/environments/direnv/modules/nginx/metadata.json
|
|
2558
2564
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile
|
|
2559
2565
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile
|
|
2560
2566
|
- spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb
|