Skip to content

Commit

Permalink
Rework syncrepl
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Mar 26, 2024
1 parent 6fb9b22 commit 9a8e9b1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifests/server/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
}
Expand Down
12 changes: 10 additions & 2 deletions spec/acceptance/openldap__server__database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]
}
}
Expand Down
15 changes: 13 additions & 2 deletions spec/defines/openldap_server_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -65,6 +73,9 @@
end

it { is_expected.to compile.with_all_deps }

Check failure on line 75 in spec/defines/openldap_server_database_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

RSpec/EmptyLineAfterExample: Add an empty line after `it`. (https://rspec.rubystyle.guide/#empty-lines-around-examples, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExample)
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
Expand Down
25 changes: 25 additions & 0 deletions types/syncrepl.pp
Original file line number Diff line number Diff line change
@@ -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],
}
]

0 comments on commit 9a8e9b1

Please sign in to comment.