puppet 6.23.0 → 6.24.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/CONTRIBUTING.md +5 -5
- data/Gemfile.lock +8 -8
- data/README.md +4 -4
- data/ext/project_data.yaml +1 -0
- data/lib/puppet.rb +3 -3
- data/lib/puppet/application/filebucket.rb +1 -0
- data/lib/puppet/application/resource.rb +15 -2
- data/lib/puppet/application/ssl.rb +1 -0
- data/lib/puppet/environments.rb +10 -0
- data/lib/puppet/face/help/action.erb +1 -0
- data/lib/puppet/face/help/face.erb +1 -0
- data/lib/puppet/face/node/clean.rb +11 -0
- data/lib/puppet/file_system/file_impl.rb +1 -1
- data/lib/puppet/file_system/windows.rb +2 -2
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/functions/empty.rb +8 -0
- data/lib/puppet/functions/strftime.rb +1 -0
- data/lib/puppet/functions/unwrap.rb +17 -2
- data/lib/puppet/indirector/resource/ral.rb +6 -1
- data/lib/puppet/interface/documentation.rb +1 -0
- data/lib/puppet/module_tool/applications/installer.rb +4 -0
- data/lib/puppet/module_tool/errors/shared.rb +17 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
- data/lib/puppet/provider/exec/posix.rb +16 -4
- data/lib/puppet/provider/package/pip.rb +15 -3
- data/lib/puppet/provider/parsedfile.rb +3 -0
- data/lib/puppet/settings.rb +30 -7
- data/lib/puppet/type/exec.rb +16 -3
- data/lib/puppet/type/file/mode.rb +6 -0
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/util/symbolic_file_mode.rb +29 -17
- data/lib/puppet/util/windows/sid.rb +3 -1
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +154 -134
- data/man/man5/puppet.conf.5 +2 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +9 -9
- 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 +8 -8
- 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 +7 -7
- 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 +5 -5
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +5 -5
- 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 +4 -4
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/ssl/127.0.0.1-key.pem +106 -106
- data/spec/fixtures/ssl/127.0.0.1.pem +48 -48
- data/spec/fixtures/ssl/bad-basic-constraints.pem +54 -54
- data/spec/fixtures/ssl/bad-int-basic-constraints.pem +51 -51
- data/spec/fixtures/ssl/ca.pem +52 -52
- data/spec/fixtures/ssl/crl.pem +25 -25
- data/spec/fixtures/ssl/ec-key.pem +11 -11
- data/spec/fixtures/ssl/ec.pem +32 -32
- data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
- data/spec/fixtures/ssl/encrypted-key.pem +107 -107
- data/spec/fixtures/ssl/intermediate-agent-crl.pem +25 -25
- data/spec/fixtures/ssl/intermediate-agent.pem +54 -54
- data/spec/fixtures/ssl/intermediate-crl.pem +28 -28
- data/spec/fixtures/ssl/intermediate.pem +51 -51
- data/spec/fixtures/ssl/oid-key.pem +117 -0
- data/spec/fixtures/ssl/oid.pem +69 -0
- data/spec/fixtures/ssl/pluto-key.pem +106 -106
- data/spec/fixtures/ssl/pluto.pem +50 -50
- data/spec/fixtures/ssl/request-key.pem +106 -106
- data/spec/fixtures/ssl/request.pem +45 -45
- data/spec/fixtures/ssl/revoked-key.pem +106 -106
- data/spec/fixtures/ssl/revoked.pem +49 -49
- data/spec/fixtures/ssl/signed-key.pem +106 -106
- data/spec/fixtures/ssl/signed.pem +47 -47
- data/spec/fixtures/ssl/tampered-cert.pem +49 -49
- data/spec/fixtures/ssl/tampered-csr.pem +45 -45
- data/spec/fixtures/ssl/trusted_oid_mapping.yaml +5 -0
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +106 -106
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -48
- data/spec/fixtures/ssl/unknown-ca-key.pem +106 -106
- data/spec/fixtures/ssl/unknown-ca.pem +52 -52
- data/spec/integration/application/filebucket_spec.rb +11 -0
- data/spec/integration/application/module_spec.rb +21 -0
- data/spec/integration/application/resource_spec.rb +35 -1
- data/spec/integration/application/ssl_spec.rb +20 -0
- data/spec/integration/environments/settings_interpolation_spec.rb +0 -4
- data/spec/integration/indirector/facts/facter_spec.rb +90 -36
- data/spec/integration/type/exec_spec.rb +70 -45
- data/spec/lib/puppet/test_ca.rb +5 -0
- data/spec/lib/puppet_spec/settings.rb +1 -0
- data/spec/unit/environments_spec.rb +35 -0
- data/spec/unit/file_system_spec.rb +6 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/empty_spec.rb +10 -0
- data/spec/unit/functions/unwrap_spec.rb +8 -0
- data/spec/unit/functions4_spec.rb +2 -2
- data/spec/unit/indirector/resource/ral_spec.rb +40 -75
- data/spec/unit/module_tool/applications/installer_spec.rb +12 -0
- data/spec/unit/parser/templatewrapper_spec.rb +12 -2
- data/spec/unit/provider/package/pip_spec.rb +37 -0
- data/spec/unit/provider/parsedfile_spec.rb +10 -0
- data/spec/unit/settings_spec.rb +97 -56
- data/spec/unit/type/exec_spec.rb +76 -29
- data/spec/unit/type/file/source_spec.rb +4 -4
- data/spec/unit/type/tidy_spec.rb +7 -0
- data/spec/unit/util/windows/sid_spec.rb +39 -4
- data/tasks/generate_cert_fixtures.rake +10 -1
- metadata +12 -3
@@ -6,30 +6,30 @@ Certificate:
|
|
6
6
|
Issuer: CN=Unknown CA
|
7
7
|
Validity
|
8
8
|
Not Before: Jan 1 00:00:00 1970 GMT
|
9
|
-
Not After :
|
9
|
+
Not After : Jun 15 01:19:37 2031 GMT
|
10
10
|
Subject: CN=Unknown CA
|
11
11
|
Subject Public Key Info:
|
12
12
|
Public Key Algorithm: rsaEncryption
|
13
13
|
RSA Public-Key: (2048 bit)
|
14
14
|
Modulus:
|
15
|
-
00:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
00:b4:79:b0:16:e7:9b:22:20:17:4b:36:87:eb:38:
|
16
|
+
03:1f:df:88:00:1b:37:40:5e:1f:1d:89:1f:3e:f4:
|
17
|
+
fa:69:90:9c:d8:68:df:c8:71:07:07:4e:01:1d:f0:
|
18
|
+
a8:9a:67:94:af:47:f2:b8:60:f5:ca:fb:bb:ac:7c:
|
19
|
+
23:58:59:bc:95:b0:ad:b2:c7:a0:28:e1:4f:1e:c4:
|
20
|
+
ef:5f:2b:a3:4e:f2:6a:95:c8:4f:f5:af:bc:fa:36:
|
21
|
+
10:f9:a9:62:7a:04:d5:01:cd:9b:ba:97:32:4c:99:
|
22
|
+
e5:88:fc:05:84:34:f5:4a:f2:f1:ec:04:c7:c7:63:
|
23
|
+
28:eb:9e:ee:91:cd:95:8b:60:9e:5f:51:a1:2b:5a:
|
24
|
+
cd:02:b2:a7:52:6c:d1:8a:ab:b1:c4:52:cd:10:ce:
|
25
|
+
9e:56:24:6c:63:84:2c:15:6c:c0:62:ea:c2:d9:04:
|
26
|
+
88:e2:e2:0f:ff:ce:87:51:eb:77:50:83:33:1c:c7:
|
27
|
+
88:5b:08:d4:3a:22:2f:13:a6:89:f7:4b:a0:2e:30:
|
28
|
+
c1:12:7a:bb:37:1f:aa:87:56:44:2f:5a:63:4b:b2:
|
29
|
+
36:f6:29:5e:b8:67:52:6f:63:2a:ad:3d:c3:a5:45:
|
30
|
+
af:97:e9:85:9e:76:1e:51:9c:68:36:58:32:ad:cf:
|
31
|
+
3e:4d:f0:92:e2:ad:d6:f0:e1:5d:af:08:ca:2a:82:
|
32
|
+
0e:a3
|
33
33
|
Exponent: 65537 (0x10001)
|
34
34
|
X509v3 extensions:
|
35
35
|
X509v3 Basic Constraints: critical
|
@@ -37,45 +37,45 @@ Certificate:
|
|
37
37
|
X509v3 Key Usage: critical
|
38
38
|
Certificate Sign, CRL Sign
|
39
39
|
X509v3 Subject Key Identifier:
|
40
|
-
|
40
|
+
D0:CD:40:49:88:F6:74:BB:B4:D7:05:37:74:33:B1:C2:27:73:81:CB
|
41
41
|
Netscape Comment:
|
42
42
|
Puppet Server Internal Certificate
|
43
43
|
X509v3 Authority Key Identifier:
|
44
|
-
keyid:
|
44
|
+
keyid:D0:CD:40:49:88:F6:74:BB:B4:D7:05:37:74:33:B1:C2:27:73:81:CB
|
45
45
|
|
46
46
|
Signature Algorithm: sha256WithRSAEncryption
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
47
|
+
51:79:86:29:27:07:e5:fc:59:83:2d:15:ae:5f:c4:bc:0a:71:
|
48
|
+
2c:71:74:20:14:ce:47:8f:cf:79:03:76:bd:df:c9:e9:7f:12:
|
49
|
+
b2:4e:5a:c5:4f:e1:0b:c3:17:44:92:37:af:10:08:75:9a:d9:
|
50
|
+
c5:0d:66:e9:24:2b:ec:00:aa:de:2f:ce:df:04:fa:49:d9:bd:
|
51
|
+
bd:5e:7b:e4:e7:1e:9e:20:d3:85:70:b4:95:b5:1d:2e:fa:0c:
|
52
|
+
b4:47:5a:38:ec:b0:bd:7e:34:5f:4d:9d:1f:81:81:8a:6c:a6:
|
53
|
+
94:fb:f8:41:d6:a3:e4:64:3a:b7:12:4f:9e:4e:60:4a:12:a9:
|
54
|
+
d1:87:a5:a8:31:91:16:96:50:73:87:64:46:f1:f2:f9:99:80:
|
55
|
+
a2:89:e9:99:57:48:8a:56:08:d7:8d:a9:1d:69:7c:8f:73:e5:
|
56
|
+
53:2d:28:ee:70:d7:f8:fe:41:25:3e:4c:6c:de:31:3f:9e:7d:
|
57
|
+
c4:f0:67:e9:fc:a3:02:c7:39:19:f5:6f:59:6a:ca:bb:8c:c8:
|
58
|
+
e6:01:43:ad:95:67:3f:c0:d6:35:18:b1:6e:9f:e1:ce:c7:be:
|
59
|
+
35:f0:7b:65:e7:79:82:c3:b6:f7:48:28:98:d0:5c:3c:97:f3:
|
60
|
+
69:b3:5e:c3:a0:c5:82:02:6f:20:d0:1b:cd:43:b0:85:7e:4f:
|
61
|
+
71:b9:f3:8f
|
62
62
|
-----BEGIN CERTIFICATE-----
|
63
63
|
MIIDPTCCAiWgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDDApVbmtu
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
DwEB/
|
64
|
+
b3duIENBMB4XDTcwMDEwMTAwMDAwMFoXDTMxMDYxNTAxMTkzN1owFTETMBEGA1UE
|
65
|
+
AwwKVW5rbm93biBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALR5
|
66
|
+
sBbnmyIgF0s2h+s4Ax/fiAAbN0BeHx2JHz70+mmQnNho38hxBwdOAR3wqJpnlK9H
|
67
|
+
8rhg9cr7u6x8I1hZvJWwrbLHoCjhTx7E718ro07yapXIT/WvvPo2EPmpYnoE1QHN
|
68
|
+
m7qXMkyZ5Yj8BYQ09Ury8ewEx8djKOue7pHNlYtgnl9RoStazQKyp1Js0YqrscRS
|
69
|
+
zRDOnlYkbGOELBVswGLqwtkEiOLiD//Oh1Hrd1CDMxzHiFsI1DoiLxOmifdLoC4w
|
70
|
+
wRJ6uzcfqodWRC9aY0uyNvYpXrhnUm9jKq09w6VFr5fphZ52HlGcaDZYMq3PPk3w
|
71
|
+
kuKt1vDhXa8IyiqCDqMCAwEAAaOBlzCBlDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
|
72
|
+
DwEB/wQEAwIBBjAdBgNVHQ4EFgQU0M1ASYj2dLu01wU3dDOxwidzgcswMQYJYIZI
|
73
73
|
AYb4QgENBCQWIlB1cHBldCBTZXJ2ZXIgSW50ZXJuYWwgQ2VydGlmaWNhdGUwHwYD
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
VR0jBBgwFoAU0M1ASYj2dLu01wU3dDOxwidzgcswDQYJKoZIhvcNAQELBQADggEB
|
75
|
+
AFF5hiknB+X8WYMtFa5fxLwKcSxxdCAUzkePz3kDdr3fyel/ErJOWsVP4QvDF0SS
|
76
|
+
N68QCHWa2cUNZukkK+wAqt4vzt8E+knZvb1ee+TnHp4g04VwtJW1HS76DLRHWjjs
|
77
|
+
sL1+NF9NnR+BgYpsppT7+EHWo+RkOrcST55OYEoSqdGHpagxkRaWUHOHZEbx8vmZ
|
78
|
+
gKKJ6ZlXSIpWCNeNqR1pfI9z5VMtKO5w1/j+QSU+TGzeMT+efcTwZ+n8owLHORn1
|
79
|
+
b1lqyruMyOYBQ62VZz/A1jUYsW6f4c7HvjXwe2XneYLDtvdIKJjQXDyX82mzXsOg
|
80
|
+
xYICbyDQG81DsIV+T3G5848=
|
81
81
|
-----END CERTIFICATE-----
|
@@ -126,6 +126,17 @@ describe "puppet filebucket", unless: Puppet::Util::Platform.jruby? do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
it "lists the local filebucket even if the environment doesn't exist locally" do
|
130
|
+
Puppet[:environment] = 'doesnotexist'
|
131
|
+
Puppet::FileSystem.mkpath(Puppet[:clientbucketdir])
|
132
|
+
|
133
|
+
filebucket.command_line.args = ['backup', '--local', backup_file]
|
134
|
+
expect {
|
135
|
+
result = filebucket.run
|
136
|
+
expect(result).to eq([backup_file])
|
137
|
+
}.to output(/Computing checksum on file/).to_stdout
|
138
|
+
end
|
139
|
+
|
129
140
|
context 'diff', unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
|
130
141
|
context 'using a remote bucket' do
|
131
142
|
it 'outputs a diff between a local and remote file' do
|
@@ -65,4 +65,25 @@ describe 'puppet module', unless: Puppet::Util::Platform.jruby? do
|
|
65
65
|
.and output(%r{Unable to verify the SSL certificate}).to_stderr
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
it 'prints the complete URL it tried to connect to' do
|
70
|
+
response_proc = -> (req, res) { res.status = 404 }
|
71
|
+
|
72
|
+
# create a temp cacert bundle
|
73
|
+
ssl_file = tmpfile('systemstore')
|
74
|
+
File.write(ssl_file, server.ca_cert)
|
75
|
+
|
76
|
+
Puppet::Util.withenv("SSL_CERT_FILE" => ssl_file) do
|
77
|
+
server.start_server(response_proc: response_proc) do |port|
|
78
|
+
Puppet[:module_repository] = "https://127.0.0.1:#{port}/bogus_test/puppet"
|
79
|
+
|
80
|
+
expect {
|
81
|
+
app.command_line.args = ['install', 'puppetlabs-bacula']
|
82
|
+
app.run
|
83
|
+
}.to exit_with(1)
|
84
|
+
.and output(%r{Notice: Downloading from https://127.0.0.1:#{port}}).to_stdout
|
85
|
+
.and output(%r{https://127.0.0.1:#{port}/bogus_test/puppet/v3/releases}).to_stderr
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
68
89
|
end
|
@@ -6,7 +6,41 @@ describe "puppet resource", unless: Puppet::Util::Platform.jruby? do
|
|
6
6
|
|
7
7
|
let(:resource) { Puppet::Application[:resource] }
|
8
8
|
|
9
|
-
|
9
|
+
context 'when given an invalid environment' do
|
10
|
+
before { Puppet[:environment] = 'badenv' }
|
11
|
+
|
12
|
+
it 'falls back to the default environment' do
|
13
|
+
Puppet[:log_level] = 'debug'
|
14
|
+
|
15
|
+
expect {
|
16
|
+
resource.run
|
17
|
+
}.to exit_with(1)
|
18
|
+
.and output(/Debug: Specified environment 'badenv' does not exist on the filesystem, defaulting to 'production'/).to_stdout
|
19
|
+
.and output(/Error: Could not run: You must specify the type to display/).to_stderr
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'lists resources' do
|
23
|
+
resource.command_line.args = ['file', Puppet[:confdir]]
|
24
|
+
|
25
|
+
expect {
|
26
|
+
resource.run
|
27
|
+
}.to output(/file { '#{Puppet[:confdir]}':/).to_stdout
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'lists types from the default environment' do
|
31
|
+
modulepath = File.join(Puppet[:codedir], 'modules', 'test', 'lib', 'puppet', 'type')
|
32
|
+
FileUtils.mkdir_p(modulepath)
|
33
|
+
File.write(File.join(modulepath, 'test.rb'), 'Puppet::Type.newtype(:test)')
|
34
|
+
resource.command_line.args = ['--types']
|
35
|
+
|
36
|
+
expect {
|
37
|
+
resource.run
|
38
|
+
}.to exit_with(0).and output(/test/).to_stdout
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
context 'when handling file and tidy types' do
|
10
44
|
let!(:dir) { dir_containing('testdir', 'testfile' => 'contents') }
|
11
45
|
|
12
46
|
it 'does not raise when generating file resources' do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "puppet ssl", unless: Puppet::Util::Platform.jruby? do
|
4
|
+
context "print" do
|
5
|
+
it 'translates custom oids to their long name' do
|
6
|
+
basedir = File.expand_path("#{__FILE__}/../../../fixtures/ssl")
|
7
|
+
# registering custom oids changes global state, so shell out
|
8
|
+
output =
|
9
|
+
%x{puppet ssl show \
|
10
|
+
--certname oid \
|
11
|
+
--localcacert #{basedir}/ca.pem \
|
12
|
+
--hostcrl #{basedir}/crl.pem \
|
13
|
+
--hostprivkey #{basedir}/oid-key.pem \
|
14
|
+
--hostcert #{basedir}/oid.pem \
|
15
|
+
--trusted_oid_mapping_file #{basedir}/trusted_oid_mapping.yaml 2>&1
|
16
|
+
}
|
17
|
+
expect(output).to match(/Long name:/)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -9,10 +9,6 @@ describe "interpolating $environment" do
|
|
9
9
|
let(:confdir) { Puppet[:confdir] }
|
10
10
|
let(:cmdline_args) { ['--confdir', confdir, '--vardir', Puppet[:vardir], '--hiera_config', Puppet[:hiera_config]] }
|
11
11
|
|
12
|
-
before(:each) do
|
13
|
-
FileUtils.mkdir_p(confdir)
|
14
|
-
end
|
15
|
-
|
16
12
|
shared_examples_for "a setting that does not interpolate $environment" do
|
17
13
|
|
18
14
|
before(:each) do
|
@@ -6,6 +6,7 @@ require 'puppet/indirector/facts/facter'
|
|
6
6
|
describe Puppet::Node::Facts::Facter do
|
7
7
|
include PuppetSpec::Files
|
8
8
|
include PuppetSpec::Compiler
|
9
|
+
include PuppetSpec::Settings
|
9
10
|
|
10
11
|
before :each do
|
11
12
|
Puppet::Node::Facts.indirection.terminus_class = :facter
|
@@ -66,49 +67,102 @@ describe Puppet::Node::Facts::Facter do
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
cat = compile_to_catalog('notify { $::puppetversion: }',
|
73
|
-
Puppet::Node.indirection.find('foo'))
|
74
|
-
expect(cat.resource("Notify[#{Puppet.version.to_s}]")).to be
|
75
|
-
end
|
70
|
+
context "adding facts" do
|
71
|
+
it "adds the puppetversion fact" do
|
72
|
+
allow(Facter).to receive(:reset)
|
76
73
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
Puppet::Node.indirection.find('foo'))
|
81
|
-
end.to raise_error(Puppet::PreformattedError)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "adds the agent_specified_environment fact when set in puppet.conf" do
|
85
|
-
FileUtils.mkdir_p(Puppet[:confdir])
|
86
|
-
File.open(File.join(Puppet[:confdir], 'puppet.conf'), 'w') do |f|
|
87
|
-
f.puts("environment=bar")
|
74
|
+
cat = compile_to_catalog('notify { $::puppetversion: }',
|
75
|
+
Puppet::Node.indirection.find('foo'))
|
76
|
+
expect(cat.resource("Notify[#{Puppet.version.to_s}]")).to be
|
88
77
|
end
|
89
78
|
|
90
|
-
|
91
|
-
|
79
|
+
context "when adding the agent_specified_environment fact" do
|
80
|
+
it "does not add the fact if the agent environment is not set" do
|
81
|
+
expect do
|
82
|
+
compile_to_catalog('notify { $::agent_specified_environment: }',
|
92
83
|
Puppet::Node.indirection.find('foo'))
|
93
|
-
|
94
|
-
|
84
|
+
end.to raise_error(Puppet::PreformattedError)
|
85
|
+
end
|
95
86
|
|
96
|
-
|
97
|
-
|
98
|
-
|
87
|
+
it "does not add the fact if the agent environment is set in sections other than agent or main" do
|
88
|
+
set_puppet_conf(Puppet[:confdir], <<~CONF)
|
89
|
+
[user]
|
90
|
+
environment=bar
|
91
|
+
CONF
|
92
|
+
|
93
|
+
Puppet.initialize_settings
|
94
|
+
expect do
|
95
|
+
compile_to_catalog('notify { $::agent_specified_environment: }',
|
99
96
|
Puppet::Node.indirection.find('foo'))
|
100
|
-
|
101
|
-
|
97
|
+
end.to raise_error(Puppet::PreformattedError)
|
98
|
+
end
|
102
99
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
100
|
+
it "adds the agent_specified_environment fact when set in the agent section in puppet.conf" do
|
101
|
+
set_puppet_conf(Puppet[:confdir], <<~CONF)
|
102
|
+
[agent]
|
103
|
+
environment=bar
|
104
|
+
CONF
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
106
|
+
Puppet.initialize_settings
|
107
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
108
|
+
Puppet::Node.indirection.find('foo'))
|
109
|
+
expect(cat.resource("Notify[bar]")).to be
|
110
|
+
end
|
111
|
+
|
112
|
+
it "prefers agent_specified_environment from main if set in section other than agent" do
|
113
|
+
set_puppet_conf(Puppet[:confdir], <<~CONF)
|
114
|
+
[main]
|
115
|
+
environment=baz
|
116
|
+
|
117
|
+
[user]
|
118
|
+
environment=bar
|
119
|
+
CONF
|
120
|
+
|
121
|
+
Puppet.initialize_settings
|
122
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
123
|
+
Puppet::Node.indirection.find('foo'))
|
124
|
+
expect(cat.resource("Notify[baz]")).to be
|
125
|
+
end
|
126
|
+
|
127
|
+
it "prefers agent_specified_environment from agent if set in multiple sections" do
|
128
|
+
set_puppet_conf(Puppet[:confdir], <<~CONF)
|
129
|
+
[main]
|
130
|
+
environment=baz
|
131
|
+
|
132
|
+
[agent]
|
133
|
+
environment=bar
|
134
|
+
CONF
|
135
|
+
|
136
|
+
Puppet.initialize_settings
|
137
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
138
|
+
Puppet::Node.indirection.find('foo'))
|
139
|
+
expect(cat.resource("Notify[bar]")).to be
|
140
|
+
end
|
141
|
+
|
142
|
+
it "adds the agent_specified_environment fact when set in puppet.conf" do
|
143
|
+
set_puppet_conf(Puppet[:confdir], 'environment=bar')
|
144
|
+
|
145
|
+
Puppet.initialize_settings
|
146
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
147
|
+
Puppet::Node.indirection.find('foo'))
|
148
|
+
expect(cat.resource("Notify[bar]")).to be
|
149
|
+
end
|
150
|
+
|
151
|
+
it "adds the agent_specified_environment fact when set via command-line" do
|
152
|
+
Puppet.initialize_settings(['--environment', 'bar'])
|
153
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
154
|
+
Puppet::Node.indirection.find('foo'))
|
155
|
+
expect(cat.resource("Notify[bar]")).to be
|
156
|
+
end
|
157
|
+
|
158
|
+
it "adds the agent_specified_environment fact, preferring cli, when set in puppet.conf and via command-line" do
|
159
|
+
set_puppet_conf(Puppet[:confdir], 'environment=bar')
|
160
|
+
|
161
|
+
Puppet.initialize_settings(['--environment', 'baz'])
|
162
|
+
cat = compile_to_catalog('notify { $::agent_specified_environment: }',
|
163
|
+
Puppet::Node.indirection.find('foo'))
|
164
|
+
expect(cat.resource("Notify[baz]")).to be
|
165
|
+
end
|
166
|
+
end
|
113
167
|
end
|
114
168
|
end
|
@@ -7,70 +7,95 @@ describe Puppet::Type.type(:exec), unless: Puppet::Util::Platform.jruby? do
|
|
7
7
|
|
8
8
|
let(:catalog) { Puppet::Resource::Catalog.new }
|
9
9
|
let(:path) { tmpfile('exec_provider') }
|
10
|
-
let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
|
11
10
|
|
12
11
|
before :each do
|
13
12
|
catalog.host_config = false
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
shared_examples_for 'a valid exec resource' do
|
16
|
+
it "should execute the command" do
|
17
|
+
exec = described_class.new :command => command, :path => ENV['PATH']
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
catalog.add_resource exec
|
20
|
+
catalog.apply
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
expect(File.read(path)).to eq('foo')
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
it "should not execute the command if onlyif returns non-zero" do
|
26
|
+
exec = described_class.new(
|
27
|
+
:command => command,
|
28
|
+
:onlyif => "ruby -e 'exit 44'",
|
29
|
+
:path => ENV['PATH']
|
30
|
+
)
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
catalog.add_resource exec
|
33
|
+
catalog.apply
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
expect(Puppet::FileSystem.exist?(path)).to be_falsey
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
it "should execute the command if onlyif returns zero" do
|
39
|
+
exec = described_class.new(
|
40
|
+
:command => command,
|
41
|
+
:onlyif => "ruby -e 'exit 0'",
|
42
|
+
:path => ENV['PATH']
|
43
|
+
)
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
catalog.add_resource exec
|
46
|
+
catalog.apply
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
expect(File.read(path)).to eq('foo')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should execute the command if unless returns non-zero" do
|
52
|
+
exec = described_class.new(
|
53
|
+
:command => command,
|
54
|
+
:unless => "ruby -e 'exit 45'",
|
55
|
+
:path => ENV['PATH']
|
56
|
+
)
|
57
|
+
|
58
|
+
catalog.add_resource exec
|
59
|
+
catalog.apply
|
60
|
+
|
61
|
+
expect(File.read(path)).to eq('foo')
|
62
|
+
end
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
64
|
+
it "should not execute the command if unless returns zero" do
|
65
|
+
exec = described_class.new(
|
66
|
+
:command => command,
|
67
|
+
:unless => "ruby -e 'exit 0'",
|
68
|
+
:path => ENV['PATH']
|
69
|
+
)
|
57
70
|
|
58
|
-
|
59
|
-
|
71
|
+
catalog.add_resource exec
|
72
|
+
catalog.apply
|
60
73
|
|
61
|
-
|
74
|
+
expect(Puppet::FileSystem.exist?(path)).to be_falsey
|
75
|
+
end
|
62
76
|
end
|
63
77
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
78
|
+
context 'when command is a string' do
|
79
|
+
let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
|
80
|
+
|
81
|
+
it_behaves_like 'a valid exec resource'
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when command is an array' do
|
85
|
+
let(:command) { ['ruby', '-e', "File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }"] }
|
86
|
+
|
87
|
+
it_behaves_like 'a valid exec resource'
|
88
|
+
|
89
|
+
context 'when is invalid' do
|
90
|
+
let(:command) { [ "ruby -e 'puts 1'" ] }
|
70
91
|
|
71
|
-
|
72
|
-
|
92
|
+
it 'logs error' do
|
93
|
+
exec = described_class.new :command => command, :path => ENV['PATH']
|
94
|
+
catalog.add_resource exec
|
95
|
+
logs = catalog.apply.report.logs
|
73
96
|
|
74
|
-
|
97
|
+
expect(logs[0].message).to eql("Could not find command 'ruby -e 'puts 1''")
|
98
|
+
end
|
99
|
+
end
|
75
100
|
end
|
76
101
|
end
|