diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-09 04:25:39 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-09 04:25:39 +0000 |
commit | 8f7b191b76ed3b8996c7fa4090b81b29ad33d394 (patch) | |
tree | 0cc6c885a6ce9081f80540b98e0e5f26ec81ab02 /lib | |
parent | da6590d072cbff40525311b6d5debae0885e1054 (diff) | |
download | puppet-8f7b191b76ed3b8996c7fa4090b81b29ad33d394.tar.gz puppet-8f7b191b76ed3b8996c7fa4090b81b29ad33d394.tar.xz puppet-8f7b191b76ed3b8996c7fa4090b81b29ad33d394.zip |
fixing groups again after getting them to work with netinfo
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@641 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/transaction.rb | 1 | ||||
-rwxr-xr-x | lib/puppet/type/group.rb | 48 |
2 files changed, 25 insertions, 24 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 3ef27620e..63a6ebbd7 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -123,6 +123,7 @@ class Transaction #@@changed.push change.state.parent rescue => detail Puppet.err("%s rollback failed: %s" % [change,detail]) + next # at this point, we would normally do error handling # but i haven't decided what to do for that yet # so just record that a sync failed for a given object diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index d75146a8b..93c8d9ba3 100755 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -25,11 +25,14 @@ module Puppet # so we don't have to worry about abstracting that across # the system def retrieve - obj = @parent.getinfo(true) + if obj = @parent.getinfo(true) - method = self.class.infomethod + method = self.class.infomethod + @is = obj.send(method) + else + @is = :notfound + end - @is = obj.send(method) end end @@ -68,16 +71,10 @@ module Puppet a letter." @name = :name - def should=(gid) - if gid.is_a?(String) - if gid =~ /^[0-9]+$/ - gid = Integer(gid) - end - end - - Puppet.info "Setting gid to %s" % gid + def should=(name) + Puppet.info "Setting group name to %s" % name - @should = gid + @should = name end end @@ -96,20 +93,23 @@ module Puppet def sync obj = @parent.getinfo - # if the user either does not or should not exist... - # yes, it's a badly named method - if obj.nil? or @should == :notfound - return create() + if self.name == :name + return syncname() end - # there's a possibility that we created the user in this session - # so verify that we're actually out of sync - if self.insync? - return nil + obj = @parent.getinfo + + if obj.nil? + raise Puppet::DevError, + "Group does not exist; cannot set gid" end + if @should == :notfound + # we have to depend on the 'name' state doing the deletion + return nil + end cmd = [ - "groupmod", self.class.flag, "'%s'" % @should, @parent.name + "groupmod", self.class.xaddflag, "'%s'" % @should, @parent.name ].join(" ") output = %x{#{cmd} 2>&1} @@ -119,11 +119,11 @@ module Puppet [self.class.name, @parent.name, output] end - return :user_modified + return :group_modified end private - def create + def syncname obj = @parent.getinfo cmd = nil @@ -216,11 +216,11 @@ module Puppet def sync events = [] - obj = @parent.getinfo if self.name == :name return syncname() end + obj = @parent.getinfo if obj.nil? raise Puppet::DevError, |