diff --git a/manifests/server/database.pp b/manifests/server/database.pp index 18393606..d964ad39 100644 --- a/manifests/server/database.pp +++ b/manifests/server/database.pp @@ -21,7 +21,7 @@ Optional[Boolean] $mirrormode = undef, Optional[Boolean] $multiprovider = undef, Optional[String[1]] $syncusesubentry = undef, - Optional[Variant[String[1],Array[String[1]]]] $syncrepl = undef, + Array[Openldap::Syncrepl] $syncrepl = [], Hash[ Enum[ 'transport', @@ -87,7 +87,7 @@ mirrormode => $mirrormode, multiprovider => $multiprovider, syncusesubentry => $syncusesubentry, - syncrepl => $syncrepl, + syncrepl => $syncrepl.map |$item| { $item.map |$k, $v| { "${k}=${String($v, '%#p')}" }.join(' ') }, limits => $limits, security => $security, } diff --git a/spec/acceptance/openldap__server__database_spec.rb b/spec/acceptance/openldap__server__database_spec.rb index a3f27db3..890240f5 100644 --- a/spec/acceptance/openldap__server__database_spec.rb +++ b/spec/acceptance/openldap__server__database_spec.rb @@ -12,8 +12,16 @@ class { 'openldap::server': directory => '/var/lib/ldap', rootdn => 'cn=admin,dc=foo,dc=example,dc=com', syncrepl => [ - 'rid=1 provider=ldap://localhost searchbase="dc=foo,dc=example,dc=com"', - 'rid=2 provider=ldap://localhost searchbase="dc=foo,dc=example,dc=com"', + { + rid => 1, + provider => 'ldap://localhost', + searchbase => 'dc=foo,dc=example,dc=com', + }, + { + rid => 2, + provider => 'ldap://localhost', + searchbase => 'dc=foo,dc=example,dc=com', + }, ] } } diff --git a/spec/defines/openldap_server_database_spec.rb b/spec/defines/openldap_server_database_spec.rb index 42958ce1..8a9020b0 100644 --- a/spec/defines/openldap_server_database_spec.rb +++ b/spec/defines/openldap_server_database_spec.rb @@ -55,8 +55,16 @@ multiprovider: true, syncusesubentry: 'wxw', syncrepl: [ - 'rid=1 provider=ldap://localhost searchbase="dc=foo,dc=example,dc=com"', - 'rid=2 provider=ldap://localhost searchbase="dc=foo,dc=example,dc=com"', + { + rid: 1, + provider: 'ldap://localhost', + searchbase: 'dc=foo,dc=example,dc=com', + }, + { + rid: 2, + provider: 'ldap://localhost', + searchbase: 'dc=foo,dc=example,dc=com', + }, ], security: { tls: 1, @@ -65,6 +73,9 @@ end it { is_expected.to compile.with_all_deps } + it { + is_expected.to contain_openldap_database('dc=foo').with(syncrepl: ['rid=1 provider="ldap://localhost" searchbase="dc=foo,dc=example,dc=com"', 'rid=2 provider="ldap://localhost" searchbase="dc=foo,dc=example,dc=com"']) + } end end end diff --git a/types/syncrepl.pp b/types/syncrepl.pp new file mode 100644 index 00000000..59a33ae2 --- /dev/null +++ b/types/syncrepl.pp @@ -0,0 +1,25 @@ +type Openldap::Syncrepl = Struct[ + { + rid => Integer[0], + provider => Pattern['\Aldaps?://[^/]+\z'], + Optional['type'] => Enum['refreshOnly', 'refreshAndPersist'], + Optional[interval] => Pattern['\A\d{2}:\d{2}:\d{2}:\d{2}\z'], + Optional[searchbase] => String[1], + Optional[filter] => String[1], + Optional[scope] => Enum['sub', 'one','base'], + Optional[attrs] => String[1], + Optional[attrsonly] => Boolean[true], + Optional[sizelimit] => Integer[0], + Optional[timelimit] => Integer[0], + Optional[schemachecking] => Enum['on', 'off'], + Optional[updatedn] => String[1], + Optional[bindmethod] => Enum['simple', 'sasl'], + Optional[binddn] => String[1], + Optional[saslmech] => String[1], + Optional[authcid] => String[1], + Optional[authzid] => String[1], + Optional[credentials] => Variant[String[1], Sensitive[String[1]]], + Optional[realm] => String[1], + Optional[secprops] => String[1], + } +]