[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5rc1-120-g2247c80
Daniel Pittman
daniel at rimspace.net
Mon Feb 7 06:41:29 UTC 2011
The following commit has been merged in the upstream branch:
commit f1ab58839b5fc2d311b2c2656e480fb563acd03f
Author: James Turnbull <james at lovedthanlost.net>
Date: Wed Jan 26 08:54:55 2011 +1100
Fixed #6009 - nested member list vs directory service group provider
The Directory Service group (and user) provider behaves erratically if members
is a nested list; this happens with the following manifest:
$r = ["root"]
$a = ["daemon", "crc"]
$n = ["nobody"]
group { "testgroup":
ensure => present,
members => [$r, $a, $n]
}
This resolves the issue by flattening the list at the time we are using it;
while a more general solution might be desirable this resolves the specific
issue cleanly enough.
Original patch from Clay Caviness.
Tests by Daniel Pittman <daniel at puppetlabs.com>
Signed-off-by: Daniel Pittman <daniel at puppetlabs.com>
Signed-off-by: James Turnbull <james at lovedthanlost.net>
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb
index 965a2aa..b018803 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -442,7 +442,7 @@ class DirectoryService < Puppet::Provider::NameService
def remove_unwanted_members(current_members, new_members)
current_members.each do |member|
- if not new_members.include?(member)
+ if not new_members.flatten.include?(member)
cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-d", member, @resource[:name]]
begin
execute(cmd)
@@ -454,7 +454,7 @@ class DirectoryService < Puppet::Provider::NameService
end
def add_members(current_members, new_members)
- new_members.each do |new_member|
+ new_members.flatten.each do |new_member|
if current_members.nil? or not current_members.include?(new_member)
cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-a", new_member, @resource[:name]]
begin
diff --git a/spec/unit/provider/nameservice/directoryservice_spec.rb b/spec/unit/provider/nameservice/directoryservice_spec.rb
new file mode 100755
index 0000000..661899d
--- /dev/null
+++ b/spec/unit/provider/nameservice/directoryservice_spec.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+# We use this as a reasonable way to obtain all the support infrastructure.
+[:user, :group].each do |type_for_this_round|
+ provider_class = Puppet::Type.type(type_for_this_round).provider(:directoryservice)
+
+ describe provider_class do
+ before do
+ @resource = stub("resource")
+ @provider = provider_class.new(@resource)
+ end
+
+ it "[#6009] should handle nested arrays of members" do
+ current = ["foo", "bar", "baz"]
+ desired = ["foo", ["quux"], "qorp"]
+ group = 'example'
+
+ @resource.stubs(:[]).with(:name).returns(group)
+ @resource.stubs(:[]).with(:auth_membership).returns(true)
+ @provider.instance_variable_set(:@property_value_cache_hash,
+ { :members => current })
+
+ %w{bar baz}.each do |del|
+ @provider.expects(:execute).once.
+ with([:dseditgroup, '-o', 'edit', '-n', '.', '-d', del, group])
+ end
+
+ %w{quux qorp}.each do |add|
+ @provider.expects(:execute).once.
+ with([:dseditgroup, '-o', 'edit', '-n', '.', '-a', add, group])
+ end
+
+ expect { @provider.set(:members, desired) }.should_not raise_error
+ end
+ end
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list