Skip to content

Commit

Permalink
Allow RHEL8+ to configure the slapd binary when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gcoxmoz committed Dec 11, 2024
1 parent 28a4084 commit 8549439
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ The following parameters are available in the `openldap::server` class:
* [`databases`](#-openldap--server--databases)
* [`ldap_ifs`](#-openldap--server--ldap_ifs)
* [`ldaps_ifs`](#-openldap--server--ldaps_ifs)
* [`slapd_path`](#-openldap--server--slapd_path)
* [`slapd_params`](#-openldap--server--slapd_params)
* [`ldap_port`](#-openldap--server--ldap_port)
* [`ldap_address`](#-openldap--server--ldap_address)
Expand Down Expand Up @@ -652,6 +653,14 @@ Data type: `Array[String[1]]`

Default value: `[]`

##### <a name="-openldap--server--slapd_path"></a>`slapd_path`

Data type: `Optional[Stdlib::Absolutepath]`



Default value: `undef`

##### <a name="-openldap--server--slapd_params"></a>`slapd_params`

Data type: `Optional[String]`
Expand Down
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Hash $databases = {},
Array[String[1]] $ldap_ifs = ['/'],
Array[String[1]] $ldaps_ifs = [],
Optional[Stdlib::Absolutepath] $slapd_path = undef,
Optional[String] $slapd_params = undef,
Optional[Stdlib::Port] $ldap_port = undef,
Optional[Stdlib::IP::Address] $ldap_address = undef,
Expand Down
8 changes: 7 additions & 1 deletion manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class openldap::server::config {
include openldap::server

$slapd_path = $openldap::server::slapd_path
$slapd_params = $openldap::server::slapd_params
$owner = $openldap::server::owner
$group = $openldap::server::group
Expand Down Expand Up @@ -120,13 +121,18 @@
}
}
if versioncmp($facts['os']['release']['major'], '8') >= 0 {
if $slapd_path != undef {
$real_slapd_path = $slapd_path
} else {
$real_slapd_path = '/usr/sbin/slapd'
}
systemd::dropin_file { 'puppet.conf':
unit => "${openldap::server::service}.service",
content => join([
'[Service]',
'EnvironmentFile=/etc/sysconfig/slapd',
'ExecStart=',
"ExecStart=/usr/sbin/slapd -u ${openldap::server::owner} -h \${SLAPD_URLS} \$SLAPD_OPTIONS",
"ExecStart=${real_slapd_path} -u ${openldap::server::owner} -h \${SLAPD_URLS} \$SLAPD_OPTIONS",
], "\n"),
}
}
Expand Down
27 changes: 27 additions & 0 deletions spec/classes/openldap_server_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
it { is_expected.not_to contain_openldap__globalconf('TLSCertificateFile') }
it { is_expected.not_to contain_openldap__globalconf('TLSCertificateKeyFile') }
it { is_expected.not_to contain_openldap__globalconf('TLSCACertificateFile') }

if (facts[:os]['family'] == 'RedHat') && (facts[:os]['release']['major'].to_i >= 8)
it { is_expected.to contain_systemd__dropin_file('puppet.conf') }
else
it { is_expected.not_to contain_systemd__dropin_file('puppet.conf') }
end
end
end

Expand All @@ -35,5 +41,26 @@
it { is_expected.to contain_shellvar('krb5_client_ktname').with(value: '/etc/krb5.keytab') }
end
end

context 'with a server binary set' do
let(:facts) do
facts
end

let :pre_condition do
"class {'openldap::server': slapd_path => '/some/odd/path', }"
end

it { is_expected.to compile.with_all_deps }

case facts[:os]['family']
when 'RedHat'
if (facts[:os]['release']['major'].to_i >= 8)
it {
is_expected.to contain_systemd__dropin_file('puppet.conf').with_content('^ExecStart=/some/odd/path')
}
end
end
end
end
end

0 comments on commit 8549439

Please sign in to comment.