puppet 3.1.0.rc1 → 3.1.0.rc2
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.
- data/COMMITTERS.md +185 -0
- data/ext/debian/changelog.erb +6 -0
- data/ext/debian/puppet-common.manpages +1 -0
- data/ext/debian/puppet.default +3 -1
- data/ext/debian/puppetmaster.default +6 -3
- data/ext/redhat/puppet.spec.erb +16 -5
- data/lib/puppet.rb +3 -5
- data/lib/puppet/defaults.rb +6 -5
- data/lib/puppet/dsl.rb +3 -7
- data/lib/puppet/dsl/resource_api.rb +120 -0
- data/lib/puppet/dsl/resource_type_api.rb +34 -0
- data/lib/puppet/module_tool.rb +23 -11
- data/lib/puppet/network/formats.rb +1 -1
- data/lib/puppet/node/environment.rb +1 -3
- data/lib/puppet/parser/ast/definition.rb +5 -2
- data/lib/puppet/parser/ast/hostclass.rb +3 -2
- data/lib/puppet/parser/ast/node.rb +5 -2
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +0 -10
- data/lib/puppet/parser/lexer.rb +50 -39
- data/lib/puppet/parser/parser_support.rb +29 -11
- data/lib/puppet/parser/scope.rb +2 -2
- data/lib/puppet/parser/type_loader.rb +7 -31
- data/lib/puppet/provider/package/openbsd.rb +16 -2
- data/lib/puppet/provider/package/pip.rb +11 -2
- data/lib/puppet/provider/package/portage.rb +29 -12
- data/lib/puppet/provider/service/launchd.rb +19 -14
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/user/hpux.rb +37 -2
- data/lib/puppet/resource.rb +25 -38
- data/lib/puppet/resource/type.rb +6 -14
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/ssl/certificate_authority.rb +4 -1
- data/lib/puppet/ssl/certificate_request.rb +3 -1
- data/lib/puppet/ssl/certificate_signer.rb +22 -0
- data/lib/puppet/type.rb +4 -4
- data/lib/puppet/util/methodhelper.rb +0 -19
- data/lib/puppet/util/rubygems.rb +3 -1
- data/lib/puppet/util/selinux.rb +1 -6
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +81 -95
- data/man/man8/extlookup2hiera.8 +23 -0
- data/man/man8/puppet-agent.8 +3 -3
- data/man/man8/puppet-apply.8 +2 -6
- data/man/man8/puppet-ca.8 +6 -7
- data/man/man8/puppet-catalog.8 +6 -7
- data/man/man8/puppet-cert.8 +4 -4
- data/man/man8/puppet-certificate.8 +6 -7
- data/man/man8/puppet-certificate_request.8 +6 -7
- data/man/man8/puppet-certificate_revocation_list.8 +6 -7
- data/man/man8/puppet-config.8 +4 -8
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +3 -3
- data/man/man8/puppet-facts.8 +4 -8
- data/man/man8/puppet-file.8 +6 -7
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +2 -6
- data/man/man8/puppet-inspect.8 +1 -1
- data/man/man8/puppet-instrumentation_data.8 +3 -7
- data/man/man8/puppet-instrumentation_listener.8 +3 -7
- data/man/man8/puppet-instrumentation_probe.8 +3 -7
- data/man/man8/puppet-key.8 +6 -7
- data/man/man8/puppet-kick.8 +5 -1
- data/man/man8/puppet-man.8 +2 -6
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +11 -9
- data/man/man8/puppet-node.8 +38 -37
- data/man/man8/puppet-parser.8 +2 -6
- data/man/man8/puppet-plugin.8 +2 -6
- data/man/man8/puppet-queue.8 +1 -1
- data/man/man8/puppet-report.8 +3 -7
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-resource_type.8 +3 -7
- data/man/man8/puppet-secret_agent.8 +2 -6
- data/man/man8/puppet-status.8 +3 -7
- data/man/man8/puppet.8 +1 -1
- data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
- data/spec/lib/puppet_spec/compiler.rb +0 -11
- data/spec/spec_helper.rb +3 -4
- data/spec/unit/dsl/resource_api_spec.rb +180 -0
- data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
- data/spec/unit/module_tool_spec.rb +79 -46
- data/spec/unit/network/formats_spec.rb +4 -0
- data/spec/unit/node/environment_spec.rb +0 -13
- data/spec/unit/parser/compiler_spec.rb +0 -26
- data/spec/unit/parser/parser_spec.rb +14 -0
- data/spec/unit/parser/type_loader_spec.rb +4 -15
- data/spec/unit/provider/package/openbsd_spec.rb +148 -35
- data/spec/unit/provider/package/pip_spec.rb +49 -25
- data/spec/unit/provider/package/portage_spec.rb +65 -0
- data/spec/unit/provider/service/launchd_spec.rb +6 -5
- data/spec/unit/provider/user/hpux_spec.rb +39 -11
- data/spec/unit/provider/user/useradd_spec.rb +14 -14
- data/spec/unit/resource/type_spec.rb +7 -49
- data/spec/unit/resource_spec.rb +0 -32
- data/spec/unit/ssl/certificate_request_spec.rb +18 -0
- data/spec/unit/util/rubygems_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +0 -2
- metadata +17 -50
- data/lib/puppet/dsl/actions.rb +0 -283
- data/lib/puppet/dsl/blank_slate.rb +0 -55
- data/lib/puppet/dsl/context.rb +0 -393
- data/lib/puppet/dsl/parser.rb +0 -57
- data/lib/puppet/dsl/resource_decorator.rb +0 -56
- data/lib/puppet/dsl/resource_reference.rb +0 -95
- data/lib/puppet/dsl/type_reference.rb +0 -102
- data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
- data/spec/integration/dsl/classes_spec.rb +0 -191
- data/spec/integration/dsl/defaults_spec.rb +0 -38
- data/spec/integration/dsl/definitions_spec.rb +0 -73
- data/spec/integration/dsl/functions_spec.rb +0 -95
- data/spec/integration/dsl/nodes_spec.rb +0 -96
- data/spec/integration/dsl/params_spec.rb +0 -146
- data/spec/integration/dsl/relationships_spec.rb +0 -46
- data/spec/integration/dsl/resources_spec.rb +0 -202
- data/spec/integration/dsl/type_loading_spec.rb +0 -64
- data/spec/lib/matchers/catalog.rb +0 -50
- data/spec/lib/puppet_spec/dsl.rb +0 -29
- data/spec/unit/dsl/actions_spec.rb +0 -402
- data/spec/unit/dsl/blank_slate_spec.rb +0 -27
- data/spec/unit/dsl/context_spec.rb +0 -678
- data/spec/unit/dsl/parser_spec.rb +0 -56
- data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
- data/spec/unit/dsl/resource_reference_spec.rb +0 -150
- data/spec/unit/dsl/type_reference_spec.rb +0 -164
- data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -211,6 +211,24 @@ describe Puppet::SSL::CertificateRequest do
|
|
211
211
|
generated.should be_a(OpenSSL::X509::Request)
|
212
212
|
generated.should be(request.content)
|
213
213
|
end
|
214
|
+
|
215
|
+
it "should use SHA1 to sign the csr when SHA256 isn't available" do
|
216
|
+
csr = OpenSSL::X509::Request.new
|
217
|
+
OpenSSL::Digest.expects(:const_defined?).with("SHA256").returns(false)
|
218
|
+
OpenSSL::Digest.expects(:const_defined?).with("SHA1").returns(true)
|
219
|
+
signer = Puppet::SSL::CertificateSigner.new
|
220
|
+
signer.sign(csr, key.content)
|
221
|
+
csr.verify(key.content).should be_true
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should raise an error if neither SHA256 nor SHA1 are available" do
|
225
|
+
csr = OpenSSL::X509::Request.new
|
226
|
+
OpenSSL::Digest.expects(:const_defined?).with("SHA256").returns(false)
|
227
|
+
OpenSSL::Digest.expects(:const_defined?).with("SHA1").returns(false)
|
228
|
+
expect {
|
229
|
+
signer = Puppet::SSL::CertificateSigner.new
|
230
|
+
}.to raise_error(Puppet::Error)
|
231
|
+
end
|
214
232
|
end
|
215
233
|
|
216
234
|
describe "when a CSR is saved" do
|
@@ -37,7 +37,7 @@ describe Puppet::Util::RubyGems::Source do
|
|
37
37
|
before(:each) { described_class.stubs(:source).returns(Puppet::Util::RubyGems::Gems18Source) }
|
38
38
|
|
39
39
|
it "#directories returns the lib subdirs of Gem::Specification.latest_specs" do
|
40
|
-
Gem::Specification.expects(:latest_specs).returns([fake_gem])
|
40
|
+
Gem::Specification.expects(:latest_specs).with(true).returns([fake_gem])
|
41
41
|
|
42
42
|
described_class.new.directories.should == [gem_lib]
|
43
43
|
end
|
@@ -135,7 +135,6 @@ describe Puppet::Util::SELinux do
|
|
135
135
|
Selinux.stubs(:matchpathcon).with("/root/chuj", 0).returns(-1)
|
136
136
|
self.stubs(:file_lstat).with("/root/chuj").raises(Errno::EACCES, "/root/chuj")
|
137
137
|
|
138
|
-
self.expects(:warning).with("Could not stat; Permission denied - /root/chuj")
|
139
138
|
get_selinux_default_context("/root/chuj").should be_nil
|
140
139
|
end
|
141
140
|
|
@@ -145,7 +144,6 @@ describe Puppet::Util::SELinux do
|
|
145
144
|
Selinux.stubs(:matchpathcon).with("/root/chuj", 0).returns(-1)
|
146
145
|
self.stubs(:file_lstat).with("/root/chuj").raises(Errno::ENOENT, "/root/chuj")
|
147
146
|
|
148
|
-
self.expects(:warning).with("Could not stat; No such file or directory - /root/chuj")
|
149
147
|
get_selinux_default_context("/root/chuj").should be_nil
|
150
148
|
end
|
151
149
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 2371461667
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 3.1.0.
|
11
|
+
- 2
|
12
|
+
version: 3.1.0.rc2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Puppet Labs
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2013-01-
|
20
|
+
date: 2013-01-25 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: hiera
|
@@ -58,6 +58,7 @@ extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
59
59
|
|
60
60
|
files:
|
61
|
+
- COMMITTERS.md
|
61
62
|
- CONTRIBUTING.md
|
62
63
|
- Gemfile
|
63
64
|
- LICENSE
|
@@ -117,13 +118,8 @@ files:
|
|
117
118
|
- lib/puppet/daemon.rb
|
118
119
|
- lib/puppet/data_binding.rb
|
119
120
|
- lib/puppet/defaults.rb
|
120
|
-
- lib/puppet/dsl/
|
121
|
-
- lib/puppet/dsl/
|
122
|
-
- lib/puppet/dsl/context.rb
|
123
|
-
- lib/puppet/dsl/parser.rb
|
124
|
-
- lib/puppet/dsl/resource_decorator.rb
|
125
|
-
- lib/puppet/dsl/resource_reference.rb
|
126
|
-
- lib/puppet/dsl/type_reference.rb
|
121
|
+
- lib/puppet/dsl/resource_api.rb
|
122
|
+
- lib/puppet/dsl/resource_type_api.rb
|
127
123
|
- lib/puppet/dsl.rb
|
128
124
|
- lib/puppet/error.rb
|
129
125
|
- lib/puppet/external/base64.rb
|
@@ -653,6 +649,7 @@ files:
|
|
653
649
|
- lib/puppet/ssl/certificate_factory.rb
|
654
650
|
- lib/puppet/ssl/certificate_request.rb
|
655
651
|
- lib/puppet/ssl/certificate_revocation_list.rb
|
652
|
+
- lib/puppet/ssl/certificate_signer.rb
|
656
653
|
- lib/puppet/ssl/configuration.rb
|
657
654
|
- lib/puppet/ssl/digest.rb
|
658
655
|
- lib/puppet/ssl/host.rb
|
@@ -773,7 +770,6 @@ files:
|
|
773
770
|
- lib/puppet/util/log.rb
|
774
771
|
- lib/puppet/util/log_paths.rb
|
775
772
|
- lib/puppet/util/logging.rb
|
776
|
-
- lib/puppet/util/manifest_filetype_helper.rb
|
777
773
|
- lib/puppet/util/metaid.rb
|
778
774
|
- lib/puppet/util/methodhelper.rb
|
779
775
|
- lib/puppet/util/metric.rb
|
@@ -840,6 +836,7 @@ files:
|
|
840
836
|
- conf/fileserver.conf
|
841
837
|
- conf/tagmail.conf
|
842
838
|
- man/man5/puppet.conf.5
|
839
|
+
- man/man8/extlookup2hiera.8
|
843
840
|
- man/man8/puppet-agent.8
|
844
841
|
- man/man8/puppet-apply.8
|
845
842
|
- man/man8/puppet-ca.8
|
@@ -1164,15 +1161,6 @@ files:
|
|
1164
1161
|
- spec/integration/application/doc_spec.rb
|
1165
1162
|
- spec/integration/configurer_spec.rb
|
1166
1163
|
- spec/integration/defaults_spec.rb
|
1167
|
-
- spec/integration/dsl/classes_spec.rb
|
1168
|
-
- spec/integration/dsl/defaults_spec.rb
|
1169
|
-
- spec/integration/dsl/definitions_spec.rb
|
1170
|
-
- spec/integration/dsl/functions_spec.rb
|
1171
|
-
- spec/integration/dsl/nodes_spec.rb
|
1172
|
-
- spec/integration/dsl/params_spec.rb
|
1173
|
-
- spec/integration/dsl/relationships_spec.rb
|
1174
|
-
- spec/integration/dsl/resources_spec.rb
|
1175
|
-
- spec/integration/dsl/type_loading_spec.rb
|
1176
1164
|
- spec/integration/faces/ca_spec.rb
|
1177
1165
|
- spec/integration/faces/documentation_spec.rb
|
1178
1166
|
- spec/integration/file_bucket/file_spec.rb
|
@@ -1198,6 +1186,7 @@ files:
|
|
1198
1186
|
- spec/integration/parser/functions/require_spec.rb
|
1199
1187
|
- spec/integration/parser/functions_spec.rb
|
1200
1188
|
- spec/integration/parser/parser_spec.rb
|
1189
|
+
- spec/integration/parser/ruby_manifest_spec.rb
|
1201
1190
|
- spec/integration/parser/scope_spec.rb
|
1202
1191
|
- spec/integration/parser/undef_param_spec.rb
|
1203
1192
|
- spec/integration/provider/mailalias/aliases_spec.rb
|
@@ -1227,7 +1216,6 @@ files:
|
|
1227
1216
|
- spec/integration/util/windows/security_spec.rb
|
1228
1217
|
- spec/integration/util/windows/user_spec.rb
|
1229
1218
|
- spec/integration/util_spec.rb
|
1230
|
-
- spec/lib/matchers/catalog.rb
|
1231
1219
|
- spec/lib/matchers/json.rb
|
1232
1220
|
- spec/lib/puppet/face/1.0.0/huzzah.rb
|
1233
1221
|
- spec/lib/puppet/face/basetest.rb
|
@@ -1238,7 +1226,6 @@ files:
|
|
1238
1226
|
- spec/lib/puppet/indirector_testing.rb
|
1239
1227
|
- spec/lib/puppet_spec/compiler.rb
|
1240
1228
|
- spec/lib/puppet_spec/database.rb
|
1241
|
-
- spec/lib/puppet_spec/dsl.rb
|
1242
1229
|
- spec/lib/puppet_spec/files.rb
|
1243
1230
|
- spec/lib/puppet_spec/fixtures.rb
|
1244
1231
|
- spec/lib/puppet_spec/matchers.rb
|
@@ -1287,13 +1274,8 @@ files:
|
|
1287
1274
|
- spec/unit/configurer_spec.rb
|
1288
1275
|
- spec/unit/daemon_spec.rb
|
1289
1276
|
- spec/unit/data_binding_spec.rb
|
1290
|
-
- spec/unit/dsl/
|
1291
|
-
- spec/unit/dsl/
|
1292
|
-
- spec/unit/dsl/context_spec.rb
|
1293
|
-
- spec/unit/dsl/parser_spec.rb
|
1294
|
-
- spec/unit/dsl/resource_decorator_spec.rb
|
1295
|
-
- spec/unit/dsl/resource_reference_spec.rb
|
1296
|
-
- spec/unit/dsl/type_reference_spec.rb
|
1277
|
+
- spec/unit/dsl/resource_api_spec.rb
|
1278
|
+
- spec/unit/dsl/resource_type_api_spec.rb
|
1297
1279
|
- spec/unit/face/catalog_spec.rb
|
1298
1280
|
- spec/unit/face/certificate_request_spec.rb
|
1299
1281
|
- spec/unit/face/certificate_revocation_list_spec.rb
|
@@ -1600,6 +1582,7 @@ files:
|
|
1600
1582
|
- spec/unit/provider/package/pkgdmg_spec.rb
|
1601
1583
|
- spec/unit/provider/package/pkgin_spec.rb
|
1602
1584
|
- spec/unit/provider/package/pkgutil_spec.rb
|
1585
|
+
- spec/unit/provider/package/portage_spec.rb
|
1603
1586
|
- spec/unit/provider/package/rpm_spec.rb
|
1604
1587
|
- spec/unit/provider/package/sun_spec.rb
|
1605
1588
|
- spec/unit/provider/package/up2date_spec.rb
|
@@ -1775,7 +1758,6 @@ files:
|
|
1775
1758
|
- spec/unit/util/log/rate_limited_logger_spec.rb
|
1776
1759
|
- spec/unit/util/log_spec.rb
|
1777
1760
|
- spec/unit/util/logging_spec.rb
|
1778
|
-
- spec/unit/util/manifest_filetype_helper_spec.rb
|
1779
1761
|
- spec/unit/util/metric_spec.rb
|
1780
1762
|
- spec/unit/util/monkey_patches/lines_spec.rb
|
1781
1763
|
- spec/unit/util/monkey_patches_spec.rb
|
@@ -1986,15 +1968,6 @@ test_files:
|
|
1986
1968
|
- spec/integration/application/doc_spec.rb
|
1987
1969
|
- spec/integration/configurer_spec.rb
|
1988
1970
|
- spec/integration/defaults_spec.rb
|
1989
|
-
- spec/integration/dsl/classes_spec.rb
|
1990
|
-
- spec/integration/dsl/defaults_spec.rb
|
1991
|
-
- spec/integration/dsl/definitions_spec.rb
|
1992
|
-
- spec/integration/dsl/functions_spec.rb
|
1993
|
-
- spec/integration/dsl/nodes_spec.rb
|
1994
|
-
- spec/integration/dsl/params_spec.rb
|
1995
|
-
- spec/integration/dsl/relationships_spec.rb
|
1996
|
-
- spec/integration/dsl/resources_spec.rb
|
1997
|
-
- spec/integration/dsl/type_loading_spec.rb
|
1998
1971
|
- spec/integration/faces/ca_spec.rb
|
1999
1972
|
- spec/integration/faces/documentation_spec.rb
|
2000
1973
|
- spec/integration/file_bucket/file_spec.rb
|
@@ -2020,6 +1993,7 @@ test_files:
|
|
2020
1993
|
- spec/integration/parser/functions/require_spec.rb
|
2021
1994
|
- spec/integration/parser/functions_spec.rb
|
2022
1995
|
- spec/integration/parser/parser_spec.rb
|
1996
|
+
- spec/integration/parser/ruby_manifest_spec.rb
|
2023
1997
|
- spec/integration/parser/scope_spec.rb
|
2024
1998
|
- spec/integration/parser/undef_param_spec.rb
|
2025
1999
|
- spec/integration/provider/mailalias/aliases_spec.rb
|
@@ -2049,7 +2023,6 @@ test_files:
|
|
2049
2023
|
- spec/integration/util/windows/security_spec.rb
|
2050
2024
|
- spec/integration/util/windows/user_spec.rb
|
2051
2025
|
- spec/integration/util_spec.rb
|
2052
|
-
- spec/lib/matchers/catalog.rb
|
2053
2026
|
- spec/lib/matchers/json.rb
|
2054
2027
|
- spec/lib/puppet/face/1.0.0/huzzah.rb
|
2055
2028
|
- spec/lib/puppet/face/basetest.rb
|
@@ -2060,7 +2033,6 @@ test_files:
|
|
2060
2033
|
- spec/lib/puppet/indirector_testing.rb
|
2061
2034
|
- spec/lib/puppet_spec/compiler.rb
|
2062
2035
|
- spec/lib/puppet_spec/database.rb
|
2063
|
-
- spec/lib/puppet_spec/dsl.rb
|
2064
2036
|
- spec/lib/puppet_spec/files.rb
|
2065
2037
|
- spec/lib/puppet_spec/fixtures.rb
|
2066
2038
|
- spec/lib/puppet_spec/matchers.rb
|
@@ -2109,13 +2081,8 @@ test_files:
|
|
2109
2081
|
- spec/unit/configurer_spec.rb
|
2110
2082
|
- spec/unit/daemon_spec.rb
|
2111
2083
|
- spec/unit/data_binding_spec.rb
|
2112
|
-
- spec/unit/dsl/
|
2113
|
-
- spec/unit/dsl/
|
2114
|
-
- spec/unit/dsl/context_spec.rb
|
2115
|
-
- spec/unit/dsl/parser_spec.rb
|
2116
|
-
- spec/unit/dsl/resource_decorator_spec.rb
|
2117
|
-
- spec/unit/dsl/resource_reference_spec.rb
|
2118
|
-
- spec/unit/dsl/type_reference_spec.rb
|
2084
|
+
- spec/unit/dsl/resource_api_spec.rb
|
2085
|
+
- spec/unit/dsl/resource_type_api_spec.rb
|
2119
2086
|
- spec/unit/face/catalog_spec.rb
|
2120
2087
|
- spec/unit/face/certificate_request_spec.rb
|
2121
2088
|
- spec/unit/face/certificate_revocation_list_spec.rb
|
@@ -2422,6 +2389,7 @@ test_files:
|
|
2422
2389
|
- spec/unit/provider/package/pkgdmg_spec.rb
|
2423
2390
|
- spec/unit/provider/package/pkgin_spec.rb
|
2424
2391
|
- spec/unit/provider/package/pkgutil_spec.rb
|
2392
|
+
- spec/unit/provider/package/portage_spec.rb
|
2425
2393
|
- spec/unit/provider/package/rpm_spec.rb
|
2426
2394
|
- spec/unit/provider/package/sun_spec.rb
|
2427
2395
|
- spec/unit/provider/package/up2date_spec.rb
|
@@ -2597,7 +2565,6 @@ test_files:
|
|
2597
2565
|
- spec/unit/util/log/rate_limited_logger_spec.rb
|
2598
2566
|
- spec/unit/util/log_spec.rb
|
2599
2567
|
- spec/unit/util/logging_spec.rb
|
2600
|
-
- spec/unit/util/manifest_filetype_helper_spec.rb
|
2601
2568
|
- spec/unit/util/metric_spec.rb
|
2602
2569
|
- spec/unit/util/monkey_patches/lines_spec.rb
|
2603
2570
|
- spec/unit/util/monkey_patches_spec.rb
|
data/lib/puppet/dsl/actions.rb
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
require 'puppet/dsl/resource_decorator'
|
2
|
-
require 'puppet/dsl/type_reference'
|
3
|
-
require 'puppet/util/methodhelper'
|
4
|
-
|
5
|
-
module Puppet
|
6
|
-
# @since 3.1
|
7
|
-
# @status EXPERIMENTAL
|
8
|
-
module DSL
|
9
|
-
|
10
|
-
# {Puppet::DSL::Context} delegates most calls to this class since itself is based
|
11
|
-
# on {BlankSlate}. This simplifies the implementation and makes debugging easier.
|
12
|
-
##
|
13
|
-
class Actions
|
14
|
-
include Puppet::Util::MethodHelper
|
15
|
-
|
16
|
-
# The filename argument is only used when creating new nodes, definitions
|
17
|
-
# or classes.
|
18
|
-
# @overload initialize()
|
19
|
-
# @overload initialize(filename)
|
20
|
-
# @param filename [String] required when creating nodes, definitions and classes
|
21
|
-
#
|
22
|
-
def initialize(filename)
|
23
|
-
@filename = filename
|
24
|
-
@exporting = false
|
25
|
-
@virtualizing = false
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns type reference to the given type.
|
29
|
-
# @param name [String] a type name string
|
30
|
-
# @return [TypeReference] to the type of the given name
|
31
|
-
def type_reference(name)
|
32
|
-
TypeReference.new name
|
33
|
-
end
|
34
|
-
|
35
|
-
# Checks whether resource type exists
|
36
|
-
# @param name [String] the name of the type
|
37
|
-
#
|
38
|
-
def is_resource_type?(name)
|
39
|
-
type = Puppet::Resource.canonicalize_type(name)
|
40
|
-
!!(["Node", "Class"].include? type or
|
41
|
-
Puppet::Type.type type or
|
42
|
-
Parser.known_resource_types.find_definition '', type or
|
43
|
-
Parser.known_resource_types.find_hostclass '', type)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Checks whether Puppet function exists
|
47
|
-
# @param [String] the name of the function
|
48
|
-
def is_function?(name)
|
49
|
-
!!Puppet::Parser::Functions.function(name)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Returns object for accessing params hash (an object that responds to #[]).
|
53
|
-
# All keys will be stringified
|
54
|
-
# @return [#[]] object for looking up parameters
|
55
|
-
#
|
56
|
-
def params
|
57
|
-
Parser.current_scope
|
58
|
-
end
|
59
|
-
|
60
|
-
# Creates a new Puppet node. All arguments have to be passed.
|
61
|
-
# Nesting is the number of nested blocks in Ruby DSL (this can be
|
62
|
-
# basically 0 or 1). Nodes can be only created in the top level scope
|
63
|
-
#
|
64
|
-
# @param name [String, Regexp] the name match for hostname
|
65
|
-
# @option options [String] :inherits name of parent/super node
|
66
|
-
# @param nesting [Fixnum] 0 if topscope else > 0
|
67
|
-
# @param code [Proc] the body of the created node, evaluated later as Ruby DSL
|
68
|
-
#
|
69
|
-
# @return [void]
|
70
|
-
# @raise [NoMethodError] if nesting > 0
|
71
|
-
# @raise [ArgumentError] if block is missing
|
72
|
-
#
|
73
|
-
def create_node(name, options, nesting, &code)
|
74
|
-
raise NoMethodError, "nodes can be only created in top level scope" if nesting > 0
|
75
|
-
raise ArgumentError, "no block supplied" if code.nil?
|
76
|
-
|
77
|
-
validate_options [:inherits], options
|
78
|
-
|
79
|
-
name = name.to_s unless name.is_a? Regexp
|
80
|
-
parent = options[:inherits].to_s if options[:inherits]
|
81
|
-
node = Puppet::Resource::Type.new :node, name, :parent => parent
|
82
|
-
node.ruby_code << Context.new(code, :filename => @filename, :nesting => nesting + 1)
|
83
|
-
|
84
|
-
Parser.known_resource_types.add_node node
|
85
|
-
end
|
86
|
-
|
87
|
-
# Creates a new hostclass. All arguments are required.
|
88
|
-
# Nesting is the number of nested blocks in Ruby DSL (this can be
|
89
|
-
# basically 0 or 1). Classes can be only created in the top level scope.
|
90
|
-
#
|
91
|
-
# @param name [String] the name of the class
|
92
|
-
# @option options [String] :inherits name of parent/super class
|
93
|
-
# @option options [Hash] :arguments map of parameter name to value
|
94
|
-
# @param nesting [Fixnum] 0 if topscope else > 0
|
95
|
-
# @param code [Proc] the body of the created hostclass, evaluated later as Ruby DSL
|
96
|
-
#
|
97
|
-
# @return [void]
|
98
|
-
# @raise [NoMethodError] if nesting > 0
|
99
|
-
# @raise [ArgumentError] if block is missing
|
100
|
-
#
|
101
|
-
def create_hostclass(name, options, nesting, &code)
|
102
|
-
raise NoMethodError, "classes can be only created in top level scope" if nesting > 0
|
103
|
-
raise ArgumentError, "no block supplied" if code.nil?
|
104
|
-
|
105
|
-
validate_options [:inherits, :arguments], options
|
106
|
-
|
107
|
-
hostclass = Puppet::Resource::Type.new :hostclass, name.to_s, :arguments => options[:arguments], :parent => options[:inherits].to_s
|
108
|
-
hostclass.ruby_code << Context.new(code, :filename => @filename, :nesting => nesting + 1)
|
109
|
-
|
110
|
-
Parser.known_resource_types.add_hostclass hostclass
|
111
|
-
end
|
112
|
-
|
113
|
-
# Creates a new definition. All arguments are required.
|
114
|
-
# Nesting is the number of nested blocks in Ruby DSL (this can be
|
115
|
-
# basically 0 or 1). Definitions can be only created in the top level scope.
|
116
|
-
#
|
117
|
-
# @param name [String] the name of the definition
|
118
|
-
# @option options [Hash] :arguments map of parameter name to value
|
119
|
-
# @param nesting [Fixnum] 0 if topscope else > 0
|
120
|
-
# @param code [Proc] the body of the created definition, evaluated later as Ruby DSL
|
121
|
-
#
|
122
|
-
# @return [void]
|
123
|
-
# @raise [NoMethodError] if nesting > 0
|
124
|
-
# @raise [ArgumentError] if block is missing
|
125
|
-
#
|
126
|
-
def create_definition(name, options, nesting, &code)
|
127
|
-
raise NoMethodError, "definitions can be only created in top level scope" if nesting > 0
|
128
|
-
raise ArgumentError, "no block supplied" if code.nil?
|
129
|
-
|
130
|
-
validate_options [:arguments], options
|
131
|
-
|
132
|
-
definition = Puppet::Resource::Type.new :definition, name.to_s, options
|
133
|
-
definition.ruby_code << Context.new(code, :filename => @filename, :nesting => nesting + 1)
|
134
|
-
|
135
|
-
Parser.known_resource_types.add_definition definition
|
136
|
-
end
|
137
|
-
|
138
|
-
# Creates a resource, all arguments are required.
|
139
|
-
# Type is a Puppet Type of a resource,
|
140
|
-
# Code is a proc that will set additional parameters, can be nil.
|
141
|
-
#
|
142
|
-
# @overload create_resource(type, args, options, {|r| block})
|
143
|
-
# @param type [Symbol] name of resource type
|
144
|
-
# @param args [String, Array<String>] one or several instance names
|
145
|
-
# @param options [Hash] mapping from resource attribute name to value, including mapping of
|
146
|
-
# non attribute names :export and :virtual. The set of valid names is determined by the resource type.
|
147
|
-
# @yieldparam r [ResourceDecorator] allows manipulating the created resource
|
148
|
-
# @param block [ruby] evaluated immediately to allow further manipulation of parameters (can be nil)
|
149
|
-
# @return [Puppet::Parser::Resource] the created resource
|
150
|
-
#
|
151
|
-
# @raise [NoMethodError] if attempt is made to create resource while manifest is imported
|
152
|
-
#
|
153
|
-
def create_resource(type, args, options, code)
|
154
|
-
# when performing type import the scope is nil
|
155
|
-
raise NoMethodError, "resources can't be created in top level scope when importing a manifest" if Parser.current_scope.nil?
|
156
|
-
|
157
|
-
ResourceDecorator.new(options, &code) if code
|
158
|
-
|
159
|
-
Array(args).flatten.map do |name|
|
160
|
-
# Implementation based on
|
161
|
-
# lib/puppet/parser/functions/create_resources.rb
|
162
|
-
#
|
163
|
-
name = name.to_s
|
164
|
-
scope = Parser.current_scope
|
165
|
-
|
166
|
-
case type
|
167
|
-
when :class
|
168
|
-
klass = Parser.known_resource_types.find_hostclass '', name
|
169
|
-
resource = klass.ensure_in_catalog scope, options
|
170
|
-
else
|
171
|
-
resource = Puppet::Parser::Resource.new type, name,
|
172
|
-
:scope => scope,
|
173
|
-
:source => scope.source
|
174
|
-
options.each do |key, val|
|
175
|
-
resource[key] = get_resource(val)
|
176
|
-
end
|
177
|
-
|
178
|
-
resource.virtual = true if virtualizing? or options[:virtual]
|
179
|
-
resource.exported = true if exporting? or options[:export]
|
180
|
-
|
181
|
-
definition = Parser.known_resource_types.definition name
|
182
|
-
definition.instantiate_resource scope, resource if definition
|
183
|
-
|
184
|
-
scope.compiler.add_resource scope, resource
|
185
|
-
end
|
186
|
-
resource
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
# Calls a puppet function.
|
191
|
-
# It does not validate arguments to the function.
|
192
|
-
#
|
193
|
-
# @example
|
194
|
-
# call_function :notice, "foo"
|
195
|
-
#
|
196
|
-
# @param name [Symbol] the name of the function
|
197
|
-
# @param *args arguments passed to the called function
|
198
|
-
# @return [Object, void] what the function returns, or void if function does not produce a r-value.
|
199
|
-
#
|
200
|
-
# @raise [NoMethodError] if function is not found
|
201
|
-
#
|
202
|
-
def call_function(name, *args)
|
203
|
-
# when performing type import the scope is nil
|
204
|
-
raise NoMethodError, "functions can't be called in top level scope when importing a manifest" if Parser.current_scope.nil?
|
205
|
-
Parser.current_scope.send name, *args
|
206
|
-
end
|
207
|
-
|
208
|
-
|
209
|
-
# @return [Boolean] flag indicating the _export_ state of a resource
|
210
|
-
attr_accessor :exporting
|
211
|
-
# @return [Boolean] flag indicating the _virtual_ state of a resource
|
212
|
-
attr_accessor :virtualizing
|
213
|
-
|
214
|
-
# Predicate accessor for :exporting
|
215
|
-
# @return [Boolean] true of resource is _export_ state, false otherwise
|
216
|
-
#
|
217
|
-
def exporting?
|
218
|
-
!!@exporting
|
219
|
-
end
|
220
|
-
|
221
|
-
# Predicate accessor for :virtualizing
|
222
|
-
# @return [Boolean] true of resource is _virtual_ state, false otherwise
|
223
|
-
def virtualizing?
|
224
|
-
!!@virtualizing
|
225
|
-
end
|
226
|
-
|
227
|
-
# Exports given resources. Resource references can be used.
|
228
|
-
# @see #get_resource #get_resource for what can be passed as a reference
|
229
|
-
# @param resources [Array<Object>] resources (via reference) to set in _export_ state.
|
230
|
-
# @return [void]
|
231
|
-
#
|
232
|
-
def export_resources(resources)
|
233
|
-
resources.flatten.each do |r|
|
234
|
-
get_resource(r).exported = true
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
# Virtualizes resources passed in as an array. Resource references can be used.
|
239
|
-
# @param resources [Array<Puppet::Parser::Resource] resources to set in _virtual_ state.
|
240
|
-
# @return [void]
|
241
|
-
#
|
242
|
-
def virtualize_resources(resources)
|
243
|
-
resources.flatten.each do |r|
|
244
|
-
get_resource(r).virtual = true
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
private
|
249
|
-
|
250
|
-
# Returns a resource for the passed reference
|
251
|
-
# @todo the return of o.to_s is somewhat mysterious and needs an explanation
|
252
|
-
#
|
253
|
-
# @overload get_resource(resource)
|
254
|
-
# @param resource [Puppet::Resource] a resource
|
255
|
-
# @overload get_resource(reference)
|
256
|
-
# @param reference [ResourceReference] a reference to a resource
|
257
|
-
# @overload get_resource(name)
|
258
|
-
# @param name [String] a resource name
|
259
|
-
# @overload get_resource(o)
|
260
|
-
# @param o [#to_s] ???
|
261
|
-
# @return [Puppet::Resource] the dereferenced resource
|
262
|
-
# @return [String] if reference can not be dereferenced, or not Resource, ResourceReference or String
|
263
|
-
#
|
264
|
-
def get_resource(reference)
|
265
|
-
case reference
|
266
|
-
when Puppet::Resource
|
267
|
-
reference
|
268
|
-
when ResourceReference
|
269
|
-
reference.resource
|
270
|
-
when String
|
271
|
-
# Try to look up a resource by String, if it fails (function returns
|
272
|
-
# nil) just return the string
|
273
|
-
resource = Puppet::DSL::Parser.current_scope.findresource(reference)
|
274
|
-
resource ||= reference
|
275
|
-
else
|
276
|
-
# All values have to be stringified before passing to Puppet Core
|
277
|
-
reference.to_s
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|