public
Fork of lak/puppet
Description: Server automation framework and application
Homepage: http://reductivelabs.com/trac/puppet/
Clone URL: git://github.com/ctrlaltdel/puppet.git
Use generate() instead of autorequire on Luke's advice
Francois Deppierraz (author)
Tue Jul 01 22:28:59 -0700 2008
commit  af35b87218bdf69ad820cfbf6daca87d186157fa
tree    0b30e9403858a7a5c6702d27e9413ebaef3af38d
parent  8c5c949b37d3af4439c713e6c6e57e8f4b0415ac
...
45
46
47
48
 
49
50
51
...
53
54
55
56
 
57
58
59
60
 
61
62
63
...
45
46
47
 
48
49
50
51
...
53
54
55
 
56
57
58
59
 
60
61
62
63
0
@@ -45,7 +45,7 @@ module Puppet
0
             defaultto do :absent end
0
         end
0
 
0
-        autorequire(:file) do
0
+        def generate
0
             atype = Puppet::Type.type(:file)
0
             target = self.should(:target)
0
             dir =  File.dirname(target)
0
@@ -53,11 +53,11 @@ module Puppet
0
 
0
             rels = []
0
 
0
-            unless atype[dir]
0
+            unless catalog.resource(:file, dir)
0
                 rels << atype.create(:name => dir, :ensure => :directory, :mode => 0700, :owner => user)
0
             end
0
 
0
-            unless atype[target]
0
+            unless catalog.resource(:file, target)
0
                 rels << atype.create(:name => target, :ensure => :present, :mode => 0600, :owner => user)
0
             end
0
 
...
84
85
86
87
 
 
 
 
 
88
89
90
...
95
96
97
98
 
 
99
100
101
...
107
108
109
110
 
 
111
112
113
 
 
 
114
...
84
85
86
 
87
88
89
90
91
92
93
94
...
99
100
101
 
102
103
104
105
106
...
112
113
114
 
115
116
117
118
 
119
120
121
122
0
@@ -84,7 +84,11 @@ describe ssh_authorized_key do
0
           :ensure => :present,
0
           :user   => "root")
0
 
0
-        key.autorequire.should_not == []
0
+        @catalog = Puppet::Node::Catalog.new
0
+        @catalog.add_resource key
0
+        @catalog.resource(:ssh_authorized_key, "Test").should == true
0
+        @catalog.resource(:file, File.expand_path("~root/.ssh")).should == true
0
+        @catalog.clear(true)
0
     end
0
 
0
     it "should set target when user is given" do
0
@@ -95,7 +99,8 @@ describe ssh_authorized_key do
0
           :ensure => :present,
0
           :user   => "root")
0
 
0
-        key.should(:target).should == File.expand_path("~root/.ssh/authorized_keys")
0
+        #@catalog.add_resource key
0
+        #@catalog.resource(:file, File.expand_path("~root/.ssh/authorized_keys")).should == true
0
     end
0
 
0
 
0
@@ -107,8 +112,11 @@ describe ssh_authorized_key do
0
           :ensure => :present,
0
           :target => "/tmp/home/foo/bar/.ssh/authorized_keys")
0
 
0
-        key.autorequire.should_not == []
0
+        #@catalog.add_resource key
0
+        #@catalog.resource(:file, "/tmp/home/foo/bar/.ssh/authorized_keys").should == true
0
     end
0
 
0
-    after { @class.clear }
0
+    after do
0
+      @class.clear
0
+    end
0
 end

Comments