Sha256: 39db1f61283881cc7c8a203bb18d4c38116fddff3cd8093fd70988741617adc4

Contents?: true

Size: 1.62 KB

Versions: 29

Compression:

Stored size: 1.62 KB

Contents

require 'puppet/provider/ldap'

Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do
  desc "Group management via LDAP.

    This provider requires that you have valid values for all of the
    LDAP-related settings in `puppet.conf`, including `ldapbase`.  You will
    almost definitely need settings for `ldapuser` and `ldappassword` in order
    for your clients to write to LDAP.

    Note that this provider will automatically generate a GID for you if you do
    not specify one, but it is a potentially expensive operation, as it
    iterates across all existing groups to pick the appropriate next one."

  confine :true => Puppet.features.ldap?, :false => (Puppet[:ldapuser] == "")

  # We're mapping 'members' here because we want to make it
  # easy for the ldap user provider to manage groups.  This
  # way it can just use the 'update' method in the group manager,
  # whereas otherwise it would need to replicate that code.
  manages(:posixGroup).at("ou=Groups").and.maps :name => :cn, :gid => :gidNumber, :members => :memberUid

  # Find the next gid after the current largest gid.
  provider = self
  manager.generates(:gidNumber).with do
    largest = 500
    if existing = provider.manager.search
        existing.each do |hash|
        next unless value = hash[:gid]
        num = value[0].to_i
        largest = num if num > largest
      end
    end
    largest + 1
  end

  # Convert a group name to an id.
  def self.name2id(group)
    return nil unless result = manager.search("cn=#{group}") and result.length > 0

    # Only use the first result.
    group = result[0]
    gid = group[:gid][0]
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
puppet-3.0.1 lib/puppet/provider/group/ldap.rb
puppet-3.0.1.rc1 lib/puppet/provider/group/ldap.rb
puppet-3.0.0 lib/puppet/provider/group/ldap.rb
puppet-3.0.0.rc8 lib/puppet/provider/group/ldap.rb
puppet-3.0.0.rc7 lib/puppet/provider/group/ldap.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/provider/group/ldap.rb
puppet-3.0.0.rc5 lib/puppet/provider/group/ldap.rb
puppet-3.0.0.rc4 lib/puppet/provider/group/ldap.rb
puppet-2.7.19 lib/puppet/provider/group/ldap.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/group/ldap.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/provider/group/ldap.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/group/ldap.rb
puppet-2.7.18 lib/puppet/provider/group/ldap.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/group/ldap.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/group/ldap.rb
puppet-2.7.17 lib/puppet/provider/group/ldap.rb
puppet-2.7.16 lib/puppet/provider/group/ldap.rb
puppet-2.7.14 lib/puppet/provider/group/ldap.rb
puppet-2.7.13 lib/puppet/provider/group/ldap.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/group/ldap.rb