From 8549439322da8c9ff41177ffa66e7628ca535edb Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Wed, 11 Dec 2024 22:13:30 +0000 Subject: [PATCH 1/3] Allow RHEL8+ to configure the slapd binary when needed --- REFERENCE.md | 9 +++++++ manifests/server.pp | 1 + manifests/server/config.pp | 8 +++++- spec/classes/openldap_server_config_spec.rb | 27 +++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/REFERENCE.md b/REFERENCE.md index f36fb25f..20cb1370 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -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) @@ -652,6 +653,14 @@ Data type: `Array[String[1]]` Default value: `[]` +##### `slapd_path` + +Data type: `Optional[Stdlib::Absolutepath]` + + + +Default value: `undef` + ##### `slapd_params` Data type: `Optional[String]` diff --git a/manifests/server.pp b/manifests/server.pp index 23415364..13dd59d0 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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, diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 92df2e0c..299b82e2 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -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 @@ -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"), } } diff --git a/spec/classes/openldap_server_config_spec.rb b/spec/classes/openldap_server_config_spec.rb index 3db71ada..de87fbcb 100644 --- a/spec/classes/openldap_server_config_spec.rb +++ b/spec/classes/openldap_server_config_spec.rb @@ -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 @@ -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 From 5c9a079efa32186c6ca572ce90b4a425e0dfb6ee Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Wed, 11 Dec 2024 22:22:10 +0000 Subject: [PATCH 2/3] Replace dropin_file with manage_dropin in openldap::server::config --- manifests/server/config.pp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 299b82e2..41f3785c 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -126,14 +126,15 @@ } 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=${real_slapd_path} -u ${openldap::server::owner} -h \${SLAPD_URLS} \$SLAPD_OPTIONS", - ], "\n"), + systemd::manage_dropin { 'puppet.conf': + unit => "${openldap::server::service}.service", + service_entry => { + 'EnvironmentFile' => '/etc/sysconfig/slapd', + 'ExecStart' => [ + '', + "${real_slapd_path} -u ${openldap::server::owner} -h \${SLAPD_URLS} \$SLAPD_OPTIONS", + ], + }, } } } From 60b830a5bdd673f90c63d49765d275e07a2f4351 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Wed, 11 Dec 2024 22:44:38 +0000 Subject: [PATCH 3/3] Rubocop fix --- spec/classes/openldap_server_config_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/openldap_server_config_spec.rb b/spec/classes/openldap_server_config_spec.rb index de87fbcb..ef3d970b 100644 --- a/spec/classes/openldap_server_config_spec.rb +++ b/spec/classes/openldap_server_config_spec.rb @@ -55,7 +55,7 @@ case facts[:os]['family'] when 'RedHat' - if (facts[:os]['release']['major'].to_i >= 8) + if facts[:os]['release']['major'].to_i >= 8 it { is_expected.to contain_systemd__dropin_file('puppet.conf').with_content('^ExecStart=/some/odd/path') }