[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

Andrew Shafer andrew at reductivelabs.com
Fri Jan 23 14:21:51 UTC 2009


The following commit has been merged in the master branch:
commit c005dcf2748326ea0f177d7da806a0cd4241c31d
Author: Andrew Shafer <andrew at reductivelabs.com>
Date:   Mon Dec 1 03:08:38 2008 -0700

    Ticket 1780 - Solaris RBAC roles should be autorequired
    
    Autorequire the roles that belong to the user so they will be created first

diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index c6f1ecc..9e32c89 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -279,6 +279,17 @@ module Puppet
             end
         end
 
+        #autorequire the roles that the user has
+        autorequire(:user) do
+            reqs = []
+
+            if roles_property = @parameters[:roles] and roles = roles_property.should
+                reqs += roles.split(',')
+            end
+
+            reqs
+        end
+
         newparam(:role_membership) do
             desc "Whether specified roles should be treated as the only roles
                 of which the user is a member or whether they should merely
diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb
index 6f01ab3..e408376 100755
--- a/spec/unit/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -238,4 +238,15 @@ describe user do
             lambda { @ensure.should = :role }.should_not raise_error
         end
     end
+
+    describe "when user has roles" do
+        it "should autorequire roles" do
+            testuser = Puppet.type(:user).create(:name => "testuser", :roles => "testrole")
+            testrole = Puppet.type(:user).create(:name => "testrole")
+            config = Puppet::Node::Catalog.new :testing do |conf|
+                [testuser, testrole].each { |resource| conf.add_resource resource }
+            end
+            testuser.autorequire
+        end
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list