Zach Leslie a963eabda7 Merge pull request #5 from Ziaunys/update_return_value
Return boolean false if the LDAP query function raises an exception.
2015-09-15 20:48:39 +00:00
2015-05-20 12:55:18 -07:00
2015-05-18 22:09:37 -07:00
2015-05-18 22:14:36 -07:00
2015-05-18 22:09:37 -07:00
2015-05-20 12:55:18 -07:00
2015-05-18 21:45:02 -07:00
2015-08-20 14:16:59 -07:00
2015-05-20 12:55:18 -07:00
2015-05-21 15:20:38 -07:00

Puppet-LDAPquery

Build Status

A Puppet function to query LDAP.

Dependencies

The Ruby net-ldap gem is required to communicate with LDAP.

Sample Usage

On the Master

You must set the necessary variables in puppet.conf so the master can connect to your LDAP server.

Add something like the following to your master's manifest.

$ldap_base   = hiera('ldap_base') # dc=example,dc=com
$ldap_user   = hiera('ldap_user') # cn=ldapuser,dc=puppetlabs,dc=com
$ldap_pass   = hiera('ldap_pass') # ultrasecure

package { 'net-ldap':
  ensure   => present,
  provider => 'gem'
}

file { '/etc/puppet/ldap_ca.pem':
  owner  => 'root',
  group  => '0',
  mode   => '0644',
  source => /path/to/my/ldap/ca.pem,
}

Ini_setting {
  ensure  => present,
  section => 'master',
  path    => '/etc/puppet/puppet.conf',
}

ini_setting { 'ldapserver':
  setting => 'ldapserver',
  value   => 'ldap.example.com',
}

ini_setting { 'ldapport':
  setting => 'ldapport',
  value   => '636',
}

ini_setting { 'ldapbase':
  setting => 'ldapbase',
  value   => $ldap_base,
}

ini_setting { 'ldapuser':
  setting => 'ldapuser',
  value   => $ldap_user,
}

ini_setting { 'ldappassword':
  setting => 'ldappassword',
  value   => $ldap_pass,
}

ini_setting { 'ldaptls':
  setting => 'ldaptls',
  value   => true,
}

In manifest

The ldapquery function is simple. Just passing an rfc4515 search filter will return the results of the query in list form. Optionally, a list of attributes of which to return the values may also be passed.

Consider the following manifest.

$attributes = [
  'loginshell',
  'uidnumber',
  'uid',
  'homedirectory',
]

$zach = ldapquery('(uid=zach)', $attributes)
Description
Query an LDAP server using Puppet.
Readme Apache-2.0 180 KiB
Languages
Ruby 95.1%
Dockerfile 4.9%