puppet 2.6.0 → 2.6.1
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/CHANGELOG +123 -0
- data/conf/redhat/puppet.spec +8 -2
- data/conf/solaris/smf/svc-puppetd +1 -1
- data/conf/solaris/smf/svc-puppetmasterd +1 -1
- data/conf/suse/client.init +4 -4
- data/conf/suse/fileserver.conf +12 -0
- data/conf/suse/logrotate +10 -0
- data/conf/suse/puppet.conf +25 -0
- data/conf/suse/puppet.spec +114 -49
- data/conf/suse/ruby-env.patch +17 -0
- data/conf/suse/server.init +4 -4
- data/ext/logcheck/puppet +23 -23
- data/ext/puppet-load.rb +357 -0
- data/ext/puppetstoredconfigclean.rb +3 -3
- data/ext/rack/files/config.ru +3 -5
- data/ext/vim/syntax/puppet.vim +6 -5
- data/install.rb +12 -11
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +3 -1
- data/lib/puppet/application.rb +2 -3
- data/lib/puppet/application/agent.rb +4 -0
- data/lib/puppet/application/apply.rb +14 -6
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/doc.rb +2 -36
- data/lib/puppet/application/master.rb +0 -3
- data/lib/puppet/application/queue.rb +1 -0
- data/lib/puppet/configurer.rb +4 -0
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +38 -44
- data/lib/puppet/file_serving/indirection_hooks.rb +2 -2
- data/lib/puppet/indirector/facts/memory.rb +1 -1
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +9 -53
- data/lib/puppet/indirector/node/memory.rb +1 -1
- data/lib/puppet/indirector/yaml.rb +6 -9
- data/lib/puppet/network/format_handler.rb +6 -0
- data/lib/puppet/network/formats.rb +4 -4
- data/lib/puppet/network/http/handler.rb +1 -1
- data/lib/puppet/network/http/rack.rb +3 -0
- data/lib/puppet/network/http/rack/rest.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +6 -3
- data/lib/puppet/node/environment.rb +15 -5
- data/lib/puppet/parameter/value_collection.rb +3 -3
- data/lib/puppet/parser/ast/function.rb +0 -1
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/ast/resource.rb +4 -3
- data/lib/puppet/parser/ast/resource_reference.rb +9 -2
- data/lib/puppet/parser/compiler.rb +12 -14
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +2 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +157 -0
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +6 -5
- data/lib/puppet/parser/functions/md5.rb +5 -0
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +19 -19
- data/lib/puppet/parser/functions/require.rb +2 -3
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/sprintf.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +4 -2
- data/lib/puppet/parser/functions/versioncmp.rb +12 -12
- data/lib/puppet/parser/lexer.rb +13 -14
- data/lib/puppet/parser/resource.rb +2 -7
- data/lib/puppet/parser/resource/param.rb +1 -1
- data/lib/puppet/parser/scope.rb +35 -0
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/property.rb +5 -5
- data/lib/puppet/provider.rb +3 -3
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +3 -3
- data/lib/puppet/provider/group/pw.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +5 -1
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/aptrpm.rb +1 -1
- data/lib/puppet/provider/package/blastwave.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +2 -2
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +1 -1
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sunfreeware.rb +2 -2
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/bsd.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +2 -2
- data/lib/puppet/provider/service/gentoo.rb +2 -2
- data/lib/puppet/provider/service/init.rb +2 -2
- data/lib/puppet/provider/service/redhat.rb +2 -2
- data/lib/puppet/provider/user/ldap.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails/host.rb +1 -0
- data/lib/puppet/reference/configuration.rb +37 -34
- data/lib/puppet/reference/indirection.rb +3 -4
- data/lib/puppet/reference/metaparameter.rb +0 -8
- data/lib/puppet/reference/network.rb +6 -4
- data/lib/puppet/reference/providers.rb +4 -4
- data/lib/puppet/reference/report.rb +5 -6
- data/lib/puppet/reference/type.rb +14 -14
- data/lib/puppet/reports/http.rb +1 -1
- data/lib/puppet/reports/rrdgraph.rb +8 -9
- data/lib/puppet/reports/store.rb +2 -2
- data/lib/puppet/reports/tagmail.rb +12 -13
- data/lib/puppet/resource.rb +15 -115
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/type.rb +26 -3
- data/lib/puppet/resource/type_collection.rb +3 -6
- data/lib/puppet/simple_graph.rb +4 -5
- data/lib/puppet/transaction/resource_harness.rb +1 -1
- data/lib/puppet/type.rb +100 -92
- data/lib/puppet/type/augeas.rb +44 -45
- data/lib/puppet/type/computer.rb +2 -2
- data/lib/puppet/type/cron.rb +29 -29
- data/lib/puppet/type/exec.rb +66 -67
- data/lib/puppet/type/file.rb +25 -25
- data/lib/puppet/type/file/content.rb +7 -1
- data/lib/puppet/type/file/ensure.rb +13 -13
- data/lib/puppet/type/file/mode.rb +6 -6
- data/lib/puppet/type/file/selcontext.rb +5 -5
- data/lib/puppet/type/file/source.rb +36 -26
- data/lib/puppet/type/filebucket.rb +5 -6
- data/lib/puppet/type/group.rb +1 -2
- data/lib/puppet/type/host.rb +3 -6
- data/lib/puppet/type/k5login.rb +3 -3
- data/lib/puppet/type/macauthorization.rb +1 -2
- data/lib/puppet/type/mailalias.rb +0 -1
- data/lib/puppet/type/maillist.rb +0 -1
- data/lib/puppet/type/mcx.rb +9 -9
- data/lib/puppet/type/mount.rb +9 -10
- data/lib/puppet/type/notify.rb +0 -1
- data/lib/puppet/type/package.rb +34 -36
- data/lib/puppet/type/resources.rb +1 -5
- data/lib/puppet/type/schedule.rb +9 -12
- data/lib/puppet/type/selboolean.rb +2 -7
- data/lib/puppet/type/selmodule.rb +3 -4
- data/lib/puppet/type/service.rb +9 -9
- data/lib/puppet/type/ssh_authorized_key.rb +2 -3
- data/lib/puppet/type/sshkey.rb +4 -7
- data/lib/puppet/type/stage.rb +5 -4
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/user.rb +1 -2
- data/lib/puppet/type/whit.rb +7 -0
- data/lib/puppet/type/yumrepo.rb +16 -3
- data/lib/puppet/type/zfs.rb +1 -2
- data/lib/puppet/type/zone.rb +28 -28
- data/lib/puppet/type/zpool.rb +10 -5
- data/lib/puppet/util/autoload.rb +17 -5
- data/lib/puppet/util/cacher.rb +15 -10
- data/lib/puppet/util/command_line/puppetdoc +5 -5
- data/lib/puppet/util/command_line/puppetrun +0 -2
- data/lib/puppet/util/command_line/ralsh +13 -13
- data/lib/puppet/util/docs.rb +5 -12
- data/lib/puppet/util/monkey_patches.rb +5 -2
- data/lib/puppet/util/nagios_maker.rb +4 -5
- data/lib/puppet/util/provider_features.rb +2 -2
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +5 -3
- data/lib/puppet/util/reference.rb +3 -52
- data/man/man5/puppet.conf.5 +2072 -1526
- data/man/man8/filebucket.8 +104 -106
- data/man/man8/pi.8 +14 -47
- data/man/man8/puppet.8 +8 -9
- data/man/man8/puppetca.8 +168 -129
- data/man/man8/puppetd.8 +282 -226
- data/man/man8/puppetdoc.8 +103 -103
- data/man/man8/puppetmasterd.8 +51 -71
- data/man/man8/puppetqd.8 +18 -53
- data/man/man8/puppetrun.8 +163 -143
- data/man/man8/ralsh.8 +77 -114
- data/spec/integration/indirector/bucket_file/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate_request/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +1 -0
- data/spec/integration/indirector/report/rest_spec.rb +1 -0
- data/spec/integration/indirector/rest_spec.rb +1 -0
- data/spec/integration/network/server/webrick_spec.rb +1 -0
- data/spec/integration/parser/compiler_spec.rb +43 -0
- data/spec/integration/provider/mailalias/aliases_spec.rb +5 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +1 -0
- data/spec/integration/ssl/certificate_request_spec.rb +1 -0
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -0
- data/spec/integration/ssl/host_spec.rb +1 -0
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -1
- data/spec/monkey_patches/publicize_methods.rb +11 -0
- data/spec/shared_behaviours/file_serving.rb +12 -1
- data/spec/spec_helper.rb +6 -25
- data/spec/unit/application/apply_spec.rb +22 -4
- data/spec/unit/application/cert_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +0 -19
- data/spec/unit/application/master_spec.rb +1 -1
- data/spec/unit/application_spec.rb +2 -12
- data/spec/unit/indirector/node/ldap_spec.rb +19 -21
- data/spec/unit/indirector/yaml_spec.rb +18 -6
- data/spec/unit/network/http/rack/rest_spec.rb +3 -3
- data/spec/unit/network/http/webrick/rest_spec.rb +1 -0
- data/spec/unit/node/environment_spec.rb +32 -3
- data/spec/unit/node/facts_spec.rb +13 -2
- data/spec/unit/parameter/value_collection_spec.rb +2 -2
- data/spec/unit/parser/ast/leaf_spec.rb +4 -0
- data/spec/unit/parser/ast/resource_reference_spec.rb +0 -5
- data/spec/unit/parser/ast/resource_spec.rb +7 -0
- data/spec/unit/parser/compiler_spec.rb +12 -1
- data/spec/unit/parser/files_spec.rb +3 -3
- data/spec/unit/parser/functions/extlookup_spec.rb +95 -0
- data/spec/unit/parser/functions/include_spec.rb +33 -0
- data/spec/unit/parser/functions/require_spec.rb +1 -1
- data/spec/unit/parser/functions/tag_spec.rb +1 -0
- data/spec/unit/parser/lexer_spec.rb +10 -1
- data/spec/unit/parser/resource_spec.rb +3 -9
- data/spec/unit/parser/type_loader_spec.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +4 -2
- data/spec/unit/rails/resource_spec.rb +1 -1
- data/spec/unit/reports/tagmail_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/resource/type_collection_spec.rb +35 -0
- data/spec/unit/resource/type_spec.rb +19 -1
- data/spec/unit/resource_spec.rb +0 -36
- data/spec/unit/simple_graph_spec.rb +12 -2
- data/spec/unit/transaction/resource_harness_spec.rb +1 -1
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/schedule_spec.rb +1 -1
- data/spec/unit/type/service_spec.rb +8 -0
- data/spec/unit/type/user_spec.rb +5 -0
- data/spec/unit/util/backups_spec.rb +0 -1
- data/spec/unit/util/rdoc/parser_spec.rb +3 -3
- data/spec/unit/util/rdoc_spec.rb +13 -0
- data/test/certmgr/support.rb +2 -1
- data/test/language/parser.rb +6 -6
- data/test/lib/puppettest.rb +3 -23
- data/test/lib/puppettest/fakes.rb +1 -1
- data/test/lib/puppettest/support/assertions.rb +0 -2
- data/test/lib/puppettest/support/utils.rb +25 -20
- data/test/ral/manager/attributes.rb +4 -1
- metadata +15 -9
- data/conf/suse/puppet.suse.patch +0 -16
- data/ext/extlookup.rb +0 -181
- data/ext/puppetlast +0 -16
- data/tasks/rake/tracdocs.rake +0 -8
- data/test/lib/mocha_standalone.rb +0 -2
@@ -113,6 +113,13 @@ describe Puppet::Parser::AST::Resource do
|
|
113
113
|
resource("file").evaluate(@twoscope)[0].type.should == "File"
|
114
114
|
end
|
115
115
|
|
116
|
+
it "should correctly generate resources that can look up defined classes by title" do
|
117
|
+
@scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
|
118
|
+
res = resource("class").evaluate(@twoscope)[0]
|
119
|
+
res.type.should == "Class"
|
120
|
+
res.title.should == "Myresource"
|
121
|
+
end
|
122
|
+
|
116
123
|
it "should fail for resource types that do not exist" do
|
117
124
|
lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError)
|
118
125
|
end
|
@@ -430,7 +430,18 @@ describe Puppet::Parser::Compiler do
|
|
430
430
|
lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError)
|
431
431
|
end
|
432
432
|
|
433
|
-
it "should add edges from the class resources to the
|
433
|
+
it "should add edges from the class resources to the parent's stage if no stage is specified" do
|
434
|
+
main = @compiler.catalog.resource(:stage, :main)
|
435
|
+
foo_stage = resource(:stage, :foo_stage)
|
436
|
+
@compiler.add_resource(@scope, foo_stage)
|
437
|
+
resource = resource(:class, "foo")
|
438
|
+
@scope.stubs(:resource).returns(:stage => :foo_stage)
|
439
|
+
@compiler.add_resource(@scope, resource)
|
440
|
+
|
441
|
+
@compiler.catalog.should be_edge(foo_stage, resource)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "should add edges from top-level class resources to the main stage if no stage is specified" do
|
434
445
|
main = @compiler.catalog.resource(:stage, :main)
|
435
446
|
resource = resource(:class, "foo")
|
436
447
|
@compiler.add_resource(@scope, resource)
|
@@ -154,7 +154,7 @@ describe Puppet::Parser::Files do
|
|
154
154
|
|
155
155
|
it "should match against provided fully qualified patterns" do
|
156
156
|
pattern = @basepath + "/fully/qualified/pattern/*"
|
157
|
-
Dir.expects(:glob).with(pattern+'{
|
157
|
+
Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns(%w{my file list})
|
158
158
|
Puppet::Parser::Files.find_manifests(pattern)[1].should == %w{my file list}
|
159
159
|
end
|
160
160
|
|
@@ -168,7 +168,7 @@ describe Puppet::Parser::Files do
|
|
168
168
|
pattern = @basepath + "/fully/qualified/pattern/*"
|
169
169
|
file = @basepath + "/my/file"
|
170
170
|
dir = @basepath + "/my/directory"
|
171
|
-
Dir.expects(:glob).with(pattern+'{
|
171
|
+
Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns([file, dir])
|
172
172
|
FileTest.expects(:directory?).with(file).returns(false)
|
173
173
|
FileTest.expects(:directory?).with(dir).returns(true)
|
174
174
|
Puppet::Parser::Files.find_manifests(pattern)[1].should == [file]
|
@@ -176,7 +176,7 @@ describe Puppet::Parser::Files do
|
|
176
176
|
|
177
177
|
it "should return files once only" do
|
178
178
|
pattern = @basepath + "/fully/qualified/pattern/*"
|
179
|
-
Dir.expects(:glob).with(pattern+'{
|
179
|
+
Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns(%w{one two one})
|
180
180
|
Puppet::Parser::Files.find_manifests(pattern)[1].should == %w{one two}
|
181
181
|
end
|
182
182
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
describe "the extlookup function" do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@scope = Puppet::Parser::Scope.new
|
10
|
+
|
11
|
+
@scope.stubs(:environment).returns(Puppet::Node::Environment.new('production'))
|
12
|
+
Puppet::Parser::Functions.function("extlookup")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should exist" do
|
16
|
+
Puppet::Parser::Functions.function("extlookup").should == "function_extlookup"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
20
|
+
lambda { @scope.function_extlookup([]) }.should( raise_error(Puppet::ParseError))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise a ParseError if there is more than 3 arguments" do
|
24
|
+
lambda { @scope.function_extlookup(["foo", "bar", "baz", "gazonk"]) }.should( raise_error(Puppet::ParseError))
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the default" do
|
28
|
+
result = @scope.function_extlookup([ "key", "default"])
|
29
|
+
result.should == "default"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should lookup the key in a supplied datafile" do
|
33
|
+
t = Tempfile.new('extlookup.csv') do
|
34
|
+
t.puts 'key,value'
|
35
|
+
t.puts 'nonkey,nonvalue'
|
36
|
+
t.close
|
37
|
+
|
38
|
+
result = @scope.function_extlookup([ "key", "default", t.path])
|
39
|
+
result.should == "value"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return an array if the datafile contains more than two columns" do
|
44
|
+
t = Tempfile.new('extlookup.csv') do
|
45
|
+
t.puts 'key,value1,value2'
|
46
|
+
t.puts 'nonkey,nonvalue,nonvalue'
|
47
|
+
t.close
|
48
|
+
|
49
|
+
result = @scope.function_extlookup([ "key", "default", t.path])
|
50
|
+
result.should == ["value1", "value2"]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should raise an error if there's no matching key and no default" do
|
55
|
+
t = Tempfile.new('extlookup.csv') do
|
56
|
+
t.puts 'key,value'
|
57
|
+
t.puts 'nonkey,nonvalue'
|
58
|
+
t.close
|
59
|
+
|
60
|
+
result = @scope.function_extlookup([ "key", nil, t.path])
|
61
|
+
result.should == "value"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do
|
66
|
+
before do
|
67
|
+
@scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp")
|
68
|
+
File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
|
69
|
+
File.open("/tmp/two.csv","w") do |two|
|
70
|
+
two.puts "key,value2"
|
71
|
+
two.puts "key2,value_two"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "when the key is in the first file" do
|
76
|
+
@scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"])
|
77
|
+
result = @scope.function_extlookup([ "key" ])
|
78
|
+
result.should == "value1"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "when the key is in the second file" do
|
82
|
+
@scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"])
|
83
|
+
result = @scope.function_extlookup([ "key2" ])
|
84
|
+
result.should == "value_two"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should not modify extlookup_precedence data" do
|
88
|
+
variable = '%{fqdn}'
|
89
|
+
@scope.stubs(:lookupvar).with('extlookup_precedence').returns([variable,"one"])
|
90
|
+
@scope.stubs(:lookupvar).with('fqdn').returns('myfqdn')
|
91
|
+
result = @scope.function_extlookup([ "key" ])
|
92
|
+
variable.should == '%{fqdn}'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
|
+
|
5
|
+
describe "the 'include' function" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Puppet::Node::Environment.stubs(:current).returns(nil)
|
9
|
+
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
|
10
|
+
@scope = Puppet::Parser::Scope.new(:compiler => @compiler)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should exist" do
|
14
|
+
Puppet::Parser::Functions.function("include").should == "function_include"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should include a single class" do
|
18
|
+
inc = "foo"
|
19
|
+
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == [inc]}.returns([inc])
|
20
|
+
@scope.function_include("foo")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should include multiple classes" do
|
24
|
+
inc = ["foo","bar"]
|
25
|
+
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc)
|
26
|
+
@scope.function_include(["foo","bar"])
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not lazily evaluate the included class" do
|
30
|
+
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| lazy == false}.returns("foo")
|
31
|
+
@scope.function_include("foo")
|
32
|
+
end
|
33
|
+
end
|
@@ -6,7 +6,7 @@ describe "the require function" do
|
|
6
6
|
|
7
7
|
before :each do
|
8
8
|
@catalog = stub 'catalog'
|
9
|
-
@compiler = stub 'compiler', :catalog => @catalog
|
9
|
+
@compiler = stub 'compiler', :catalog => @catalog, :environment => nil
|
10
10
|
|
11
11
|
@scope = Puppet::Parser::Scope.new
|
12
12
|
@scope.stubs(:findresource)
|
@@ -410,6 +410,10 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
|
|
410
410
|
%q{'single quoted string')} => [[:STRING,'single quoted string']],
|
411
411
|
%q{"double quoted string"} => [[:STRING,'double quoted string']],
|
412
412
|
%q{'single quoted string with an escaped "\\'"'} => [[:STRING,'single quoted string with an escaped "\'"']],
|
413
|
+
%q{'single quoted string with an escaped "\$"'} => [[:STRING,'single quoted string with an escaped "\$"']],
|
414
|
+
%q{'single quoted string with an escaped "\."'} => [[:STRING,'single quoted string with an escaped "\."']],
|
415
|
+
%q{'single quoted string with an escaped "\n"'} => [[:STRING,'single quoted string with an escaped "\n"']],
|
416
|
+
%q{'single quoted string with an escaped "\\\\"'} => [[:STRING,'single quoted string with an escaped "\\\\"']],
|
413
417
|
%q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]],
|
414
418
|
%q{"string with an escaped '\\$'"} => [[:STRING,"string with an escaped '$'"]],
|
415
419
|
%q{"string with $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
|
@@ -616,6 +620,12 @@ describe "Puppet::Parser::Lexer in the old tests" do
|
|
616
620
|
@lexer.namespace.should == "base::sub"
|
617
621
|
end
|
618
622
|
|
623
|
+
it "should not put class instantiation on the namespace" do
|
624
|
+
@lexer.string = "class base { class sub { class { mode"
|
625
|
+
@lexer.fullscan
|
626
|
+
@lexer.namespace.should == "base::sub"
|
627
|
+
end
|
628
|
+
|
619
629
|
it "should correctly handle fully qualified names" do
|
620
630
|
@lexer.string = "class base { class sub::more {"
|
621
631
|
@lexer.fullscan
|
@@ -634,7 +644,6 @@ end
|
|
634
644
|
|
635
645
|
require 'puppettest/support/utils'
|
636
646
|
describe "Puppet::Parser::Lexer in the old tests when lexing example files" do
|
637
|
-
extend PuppetTest
|
638
647
|
extend PuppetTest::Support::Utils
|
639
648
|
textfiles do |file|
|
640
649
|
it "should correctly lex #{file}" do
|
@@ -58,23 +58,17 @@ describe Puppet::Parser::Resource do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should get its environment from its scope" do
|
61
|
-
scope = stub 'scope', :source => stub("source")
|
62
|
-
scope.expects(:environment).returns
|
61
|
+
scope = stub 'scope', :source => stub("source"), :namespaces => nil
|
62
|
+
scope.expects(:environment).returns("foo").at_least_once
|
63
63
|
Puppet::Parser::Resource.new("file", "whatever", :scope => scope).environment.should == "foo"
|
64
64
|
end
|
65
65
|
|
66
|
-
it "should get its namespaces from its scope" do
|
67
|
-
scope = stub 'scope', :source => stub("source")
|
68
|
-
scope.expects(:namespaces).returns %w{one two}
|
69
|
-
Puppet::Parser::Resource.new("file", "whatever", :scope => scope).namespaces.should == %w{one two}
|
70
|
-
end
|
71
|
-
|
72
66
|
it "should use the resource type collection helper module" do
|
73
67
|
Puppet::Parser::Resource.ancestors.should be_include(Puppet::Resource::TypeCollectionHelper)
|
74
68
|
end
|
75
69
|
|
76
70
|
it "should use the scope's environment as its environment" do
|
77
|
-
@scope.expects(:environment).returns
|
71
|
+
@scope.expects(:environment).returns("myenv").at_least_once
|
78
72
|
Puppet::Parser::Resource.new("file", "whatever", :scope => @scope).environment.should == "myenv"
|
79
73
|
end
|
80
74
|
|
@@ -192,7 +192,7 @@ describe Puppet::Parser::TypeLoader do
|
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should be able to add classes to the current resource type collection" do
|
195
|
-
file = tmpfile("simple_file")
|
195
|
+
file = tmpfile("simple_file.pp")
|
196
196
|
File.open(file, "w") { |f| f.puts "class foo {}" }
|
197
197
|
@loader.import(file)
|
198
198
|
|
@@ -3,14 +3,16 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
4
|
|
5
5
|
require 'puppet_spec/files'
|
6
|
-
require 'puppettest'
|
7
6
|
require 'puppettest/support/utils'
|
8
7
|
require 'puppettest/fileparsing'
|
8
|
+
require 'tmpdir'
|
9
|
+
require 'puppettest/fakes'
|
9
10
|
|
10
11
|
provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
|
11
12
|
|
12
13
|
describe provider_class do
|
13
14
|
include PuppetSpec::Files
|
15
|
+
extend PuppetTest::Support::Utils
|
14
16
|
include PuppetTest
|
15
17
|
include PuppetTest::FileParsing
|
16
18
|
|
@@ -49,7 +51,7 @@ describe provider_class do
|
|
49
51
|
@provider.target_object(@keyfile).read
|
50
52
|
end
|
51
53
|
|
52
|
-
|
54
|
+
fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
|
53
55
|
it "should be able to parse example data in #{file}" do
|
54
56
|
fakedataparse(file)
|
55
57
|
end
|
@@ -107,7 +107,7 @@ describe "Puppet::Rails::Resource" do
|
|
107
107
|
|
108
108
|
describe "#to_resource" do
|
109
109
|
it "should instantiate a Puppet::Parser::Resource" do
|
110
|
-
scope = stub "scope", :source => nil
|
110
|
+
scope = stub "scope", :source => nil, :environment => nil, :namespaces => nil
|
111
111
|
|
112
112
|
@resource = Puppet::Rails::Resource.new
|
113
113
|
@resource.stubs(:attributes).returns({
|
@@ -3,12 +3,12 @@
|
|
3
3
|
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
|
4
4
|
|
5
5
|
require 'puppet/reports'
|
6
|
-
require 'puppettest'
|
6
|
+
require 'puppettest/support/utils'
|
7
7
|
|
8
8
|
tagmail = Puppet::Reports.report(:tagmail)
|
9
9
|
|
10
10
|
describe tagmail do
|
11
|
-
extend PuppetTest
|
11
|
+
extend PuppetTest::Support::Utils
|
12
12
|
|
13
13
|
before do
|
14
14
|
@processor = Puppet::Transaction::Report.new
|
@@ -224,7 +224,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should convert parser resources to plain resources" do
|
227
|
-
resource = Puppet::Parser::Resource.new(:file, "foo", :scope => stub("scope"), :source => stub("source"))
|
227
|
+
resource = Puppet::Parser::Resource.new(:file, "foo", :scope => stub("scope", :environment => nil, :namespaces => nil), :source => stub("source"))
|
228
228
|
catalog = Puppet::Resource::Catalog.new("whev")
|
229
229
|
catalog.add_resource(resource)
|
230
230
|
new = catalog.to_resource
|
@@ -258,6 +258,32 @@ describe Puppet::Resource::TypeCollection do
|
|
258
258
|
loader.add instance
|
259
259
|
loader.find("foo::bar", "eh", :hostclass).should be_nil
|
260
260
|
end
|
261
|
+
|
262
|
+
describe "when topscope has a class that has the same name as a local class" do
|
263
|
+
before do
|
264
|
+
@loader = Puppet::Resource::TypeCollection.new("env")
|
265
|
+
[ "foo::bar", "bar" ].each do |name|
|
266
|
+
@loader.add Puppet::Resource::Type.new(:hostclass, name)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should favor the local class, if the name is unqualified" do
|
271
|
+
@loader.find("foo", "bar", :hostclass).name.should == 'foo::bar'
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should only look in the topclass, if the name is qualified" do
|
275
|
+
@loader.find("foo", "::bar", :hostclass).name.should == 'bar'
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
it "should not look in the local scope for classes when the name is qualified" do
|
281
|
+
@loader = Puppet::Resource::TypeCollection.new("env")
|
282
|
+
@loader.add Puppet::Resource::Type.new(:hostclass, "foo::bar")
|
283
|
+
|
284
|
+
@loader.find("foo", "::bar", :hostclass).should == nil
|
285
|
+
end
|
286
|
+
|
261
287
|
end
|
262
288
|
|
263
289
|
it "should use the generic 'find' method with an empty namespace to find nodes" do
|
@@ -400,6 +426,14 @@ describe Puppet::Resource::TypeCollection do
|
|
400
426
|
@parser.expects(:parse).raises ArgumentError
|
401
427
|
lambda { @code.perform_initial_import }.should raise_error(Puppet::Error)
|
402
428
|
end
|
429
|
+
|
430
|
+
it "should not do anything if the ignore_import settings is set" do
|
431
|
+
Puppet.settings[:ignoreimport] = true
|
432
|
+
@parser.expects(:string=).never
|
433
|
+
@parser.expects(:file=).never
|
434
|
+
@parser.expects(:parse).never
|
435
|
+
@code.perform_initial_import
|
436
|
+
end
|
403
437
|
end
|
404
438
|
|
405
439
|
describe "when determining the configuration version" do
|
@@ -429,4 +463,5 @@ describe Puppet::Resource::TypeCollection do
|
|
429
463
|
end
|
430
464
|
|
431
465
|
end
|
466
|
+
|
432
467
|
end
|
@@ -369,7 +369,8 @@ describe Puppet::Resource::Type do
|
|
369
369
|
end
|
370
370
|
|
371
371
|
it "should cache a reference to the parent type" do
|
372
|
-
@code.
|
372
|
+
@code.stubs(:hostclass).with("foo::bar").returns nil
|
373
|
+
@code.expects(:hostclass).with("bar").once.returns @parent
|
373
374
|
@child.parent_type(@scope)
|
374
375
|
@child.parent_type
|
375
376
|
end
|
@@ -411,6 +412,23 @@ describe Puppet::Resource::Type do
|
|
411
412
|
@type = Puppet::Resource::Type.new(:hostclass, "foo")
|
412
413
|
end
|
413
414
|
|
415
|
+
it "should add hostclass names to the classes list" do
|
416
|
+
@type.evaluate_code(@resource)
|
417
|
+
@compiler.catalog.classes.should be_include("foo")
|
418
|
+
end
|
419
|
+
|
420
|
+
it "should add node names to the classes list" do
|
421
|
+
@type = Puppet::Resource::Type.new(:node, "foo")
|
422
|
+
@type.evaluate_code(@resource)
|
423
|
+
@compiler.catalog.classes.should be_include("foo")
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should not add defined resource names to the classes list" do
|
427
|
+
@type = Puppet::Resource::Type.new(:definition, "foo")
|
428
|
+
@type.evaluate_code(@resource)
|
429
|
+
@compiler.catalog.classes.should_not be_include("foo")
|
430
|
+
end
|
431
|
+
|
414
432
|
it "should set all of its parameters in a subscope" do
|
415
433
|
subscope = stub 'subscope', :compiler => @compiler
|
416
434
|
@type.expects(:subscope).with(@scope, @resource).returns subscope
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -123,18 +123,6 @@ describe Puppet::Resource do
|
|
123
123
|
Puppet::Resource.new("file", "/my/file", :environment => :foo).environment.name.should == :foo
|
124
124
|
end
|
125
125
|
|
126
|
-
it "should support specifying namespaces" do
|
127
|
-
Puppet::Resource.new("file", "/my/file", :namespaces => ["foo"]).namespaces.should == ["foo"]
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should convert namespaces to an array if not specified as one" do
|
131
|
-
Puppet::Resource.new("file", "/my/file", :namespaces => "foo").namespaces.should == ["foo"]
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should default to a single amespace of an empty string" do
|
135
|
-
Puppet::Resource.new("file", "/my/file").namespaces.should == [""]
|
136
|
-
end
|
137
|
-
|
138
126
|
describe "and munging its type and title" do
|
139
127
|
describe "when modeling a builtin resource" do
|
140
128
|
it "should be able to find the resource type" do
|
@@ -164,16 +152,6 @@ describe Puppet::Resource do
|
|
164
152
|
it "should set its title to the provided title" do
|
165
153
|
Puppet::Resource.new("foo::bar", "/my/file").title.should == "/my/file"
|
166
154
|
end
|
167
|
-
|
168
|
-
describe "and the resource is unqualified and models a qualified resource type" do
|
169
|
-
it "should set its type to the fully qualified resource type" do
|
170
|
-
Puppet::Resource.new("bar", "/my/file", :namespaces => %w{foo}).type.should == "Foo::Bar"
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should be able to find the resource type" do
|
174
|
-
Puppet::Resource.new("bar", "/my/file", :namespaces => %w{foo}).resource_type.should equal(@type)
|
175
|
-
end
|
176
|
-
end
|
177
155
|
end
|
178
156
|
|
179
157
|
describe "that does not exist" do
|
@@ -210,20 +188,6 @@ describe Puppet::Resource do
|
|
210
188
|
it "should be able to find the resource type" do
|
211
189
|
Puppet::Resource.new("class", "foo::bar").resource_type.should equal(@type)
|
212
190
|
end
|
213
|
-
|
214
|
-
describe "and the resource is unqualified and models a qualified class" do
|
215
|
-
it "should set its title to the fully qualified resource type" do
|
216
|
-
Puppet::Resource.new("class", "bar", :namespaces => %w{foo}).title.should == "Foo::Bar"
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should be able to find the resource type" do
|
220
|
-
Puppet::Resource.new("class", "bar", :namespaces => %w{foo}).resource_type.should equal(@type)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "should set its type to 'Class'" do
|
224
|
-
Puppet::Resource.new("class", "bar", :namespaces => %w{foo}).type.should == "Class"
|
225
|
-
end
|
226
|
-
end
|
227
191
|
end
|
228
192
|
|
229
193
|
describe "that does not exist" do
|