Skip to content

Commit 2756857

Browse files
committed
Add PROXY-protocol listener support to slapd
1 parent 11b88b3 commit 2756857

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

REFERENCE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,8 @@ The following parameters are available in the `openldap::server` class:
453453

454454
* [`krb5_keytab_file`](#-openldap--server--krb5_keytab_file)
455455
* [`krb5_client_keytab_file`](#-openldap--server--krb5_client_keytab_file)
456+
* [`pldap_ifs`](#-openldap--server--pldap_ifs)
457+
* [`pldaps_ifs`](#-openldap--server--pldaps_ifs)
456458
* [`package`](#-openldap--server--package)
457459
* [`confdir`](#-openldap--server--confdir)
458460
* [`conffile`](#-openldap--server--conffile)
@@ -502,6 +504,26 @@ configuring sasl with backend GSSAPI
502504

503505
Default value: `undef`
504506

507+
##### <a name="-openldap--server--pldap_ifs"></a>`pldap_ifs`
508+
509+
Data type: `Array[String[1]]`
510+
511+
Allows to configure the HAProxy PROXY protol handling of openldap.
512+
This allows to get IPs of clients through a load-balancer for logging or filtering.
513+
Must not use the same ports as the native listeners.
514+
515+
Default value: `[]`
516+
517+
##### <a name="-openldap--server--pldaps_ifs"></a>`pldaps_ifs`
518+
519+
Data type: `Array[String[1]]`
520+
521+
Allows to configure the HAProxy PROXY protol handling of openldap.
522+
This allows to get IPs of clients through a load-balancer for logging or filtering.
523+
Must not use the same ports as the native listeners.
524+
525+
Default value: `[]`
526+
505527
##### <a name="-openldap--server--package"></a>`package`
506528

507529
Data type: `String[1]`

manifests/server.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# @param krb5_client_keytab_file
66
# if set, manage the env variable KRB5_CLIENT_KTNAME on Debian based operating systems. This is required when
77
# configuring sasl with backend GSSAPI
8+
# @param pldap_ifs
9+
# Allows to configure the HAProxy PROXY protol handling of openldap.
10+
# This allows to get IPs of clients through a load-balancer for logging or filtering.
11+
# Must not use the same ports as the native listeners.
12+
# @param pldaps_ifs
13+
# Allows to configure the HAProxy PROXY protol handling of openldap.
14+
# This allows to get IPs of clients through a load-balancer for logging or filtering.
15+
# Must not use the same ports as the native listeners.
816
class openldap::server (
917
String[1] $package,
1018
String[1] $confdir,
@@ -27,6 +35,8 @@
2735
Hash $databases = {},
2836
Array[String[1]] $ldap_ifs = ['/'],
2937
Array[String[1]] $ldaps_ifs = [],
38+
Array[String[1]] $pldaps_ifs = [],
39+
Array[String[1]] $pldap_ifs = [],
3040
Optional[String] $slapd_params = undef,
3141
Optional[Stdlib::Port] $ldap_port = undef,
3242
Optional[Stdlib::IP::Address] $ldap_address = undef,

manifests/server/config.pp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
$ldap_config_backend = $openldap::server::ldap_config_backend
1818
$enable_memory_limit = $openldap::server::enable_memory_limit
1919

20+
$slapd_pldap_ifs = empty($openldap::server::pldap_ifs) ? {
21+
false => join(prefix($openldap::server::pldap_ifs, 'pldap://'), ' '),
22+
true => '',
23+
}
2024
$slapd_ldap_ifs = empty($openldap::server::ldap_ifs) ? {
2125
false => join(prefix($openldap::server::ldap_ifs, 'ldap://'), ' '),
2226
true => '',
@@ -29,11 +33,15 @@
2933
false => join(prefix($escaped_ldapi_ifs, 'ldapi://'), ' '),
3034
true => '',
3135
}
36+
$slapd_pldaps_ifs = empty($openldap::server::pldaps_ifs) ? {
37+
false => join(prefix($openldap::server::pldaps_ifs, 'pldaps://'), ' '),
38+
true => '',
39+
}
3240
$slapd_ldaps_ifs = empty($openldap::server::ldaps_ifs) ? {
3341
false => join(prefix($openldap::server::ldaps_ifs, 'ldaps://'), ' '),
3442
true => '',
3543
}
36-
$slapd_ldap_urls = "${slapd_ldap_ifs} ${slapd_ldapi_ifs} ${slapd_ldaps_ifs}"
44+
$slapd_ldap_urls = "${slapd_ldap_ifs} ${slapd_pldap_ifs} ${slapd_ldapi_ifs} ${slapd_ldaps_ifs} ${slapd_pldaps_ifs}"
3745

3846
file { $openldap::server::confdir:
3947
ensure => directory,

spec/acceptance/openldap__server_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,34 @@ class { 'openldap::server':
7979
end
8080
end
8181
end
82+
83+
# if (fact('os.family') == 'Debian' && fact('os.release.major') == 11) ||
84+
# (fact('os.family') == 'RedHat' && fact('os.release.major') == 8)
85+
skip('Does not work on openldap 2.4')
86+
context 'when enabling PROXY Protocol' do
87+
it 'idempotentlies run' do
88+
pp = <<-EOS
89+
class { 'openldap::server':
90+
ldaps_ifs => ['/'],
91+
ssl_key => "/etc/ldap/ssl/${facts['networking']['fqdn']}.key",
92+
ssl_cert => "/etc/ldap/ssl/${facts['networking']['fqdn']}.crt",
93+
ssl_ca => '/etc/ldap/ssl/ca.pem',
94+
pldaps_ifs => ['[::]:3269/'],
95+
pldap_ifs => ['[::]:7389/'],
96+
}
97+
EOS
98+
99+
idempotent_apply(pp)
100+
end
101+
102+
# rubocop:disable RSpec/RepeatedExampleGroupBody
103+
describe port(7389) do
104+
it { is_expected.to be_listening }
105+
end
106+
107+
describe port(3269) do
108+
it { is_expected.to be_listening }
109+
end
110+
# rubocop:enable RSpec/RepeatedExampleGroupBody
111+
end
82112
end

0 commit comments

Comments
 (0)