Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework openldap::server::database interface for the syncrepl parameter #412

Merged
merged 5 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* [`Openldap::Access_title`](#Openldap--Access_title): A valid title for an openldap::server::access resource
* [`Openldap::Attribute`](#Openldap--Attribute): An LDAP attribute in the form "key: value"
* [`Openldap::Attributes`](#Openldap--Attributes): A set of LDAP attributes
* [`Openldap::Syncrepl`](#Openldap--Syncrepl): Parameters for database replication consumers
* [`Openldap::Tls_moznss_compatibility`](#Openldap--Tls_moznss_compatibility): The list of possible values TLS_MOZNSS_COMPATIBILITY can have (based on the man page), and an 'absent' (a puppet directive to remove an exist

## Classes
Expand Down Expand Up @@ -1063,11 +1064,11 @@ Default value: `undef`

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

Data type: `Optional[Variant[String[1],Array[String[1]]]]`
Data type: `Array[Openldap::Syncrepl]`



Default value: `undef`
Default value: `[]`

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

Expand Down Expand Up @@ -1800,6 +1801,59 @@ Variant[Hash[
], Openldap::Attribute]
```

### <a name="Openldap--Syncrepl"></a>`Openldap::Syncrepl`

Parameters for database replication consumers

* **See also**
* https://www.openldap.org/doc/admin26/slapdconfig.html#syncrepl

Alias of

```puppet
Struct[{
rid => Variant[Integer[0, 999], Pattern['\A\d{1,3}\z']],
provider => Pattern['\Aldaps?://[^/:]+(:\d+)?\z'],
searchbase => String[1],
Optional['type'] => Enum['refreshOnly', 'refreshAndPersist'],
Optional[interval] => Pattern['\A\d{2}:\d{2}:\d{2}:\d{2}\z'],
Optional[retry] => String[1],
Optional[filter] => String[1],
Optional[scope] => Enum['sub', 'one','base'],
Optional[attrs] => String[1],
Optional[exattrs] => String[1],
Optional[attrsonly] => Boolean,
Optional[sizelimit] => Integer[0],
Optional[timelimit] => Integer[0],
Optional[schemachecking] => Enum['on', 'off'],
Optional[network-timeout] => Integer[0],
Optional[timeout] => Integer[0],
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],
Optional[keepalive] => Pattern['\A\d{2}:\d{2}:\d{2}\z'],
Optional[starttls] => Enum['yes', 'critical'],
Optional[tls_cert] => Stdlib::Absolutepath,
Optional[tls_key] => Stdlib::Absolutepath,
Optional[tls_cacert] => Stdlib::Absolutepath,
Optional[tls_cacertdir] => Stdlib::Absolutepath,
Optional[tls_reqcert] => Enum['never', 'allow', 'try', 'demand'],
Optional[tls_cipher_suite] => String[1],
Optional[tls_crlcheck] => Enum['none', 'peer', 'all'],
Optional[tls_protocol_min] => Pattern['\A\d+(\.\d+)?\z'],
Optional[suffixmassage] => String[1],
Optional[logbase] => String[1],
Optional[logfilter] => String[1],
Optional[syncdata] => Enum['default', 'accesslog', 'changelog'],
}]
```

### <a name="Openldap--Tls_moznss_compatibility"></a>`Openldap::Tls_moznss_compatibility`

The list of possible values TLS_MOZNSS_COMPATIBILITY can have (based on the man page), and an 'absent' (a puppet directive to remove an existing declaration).
Expand Down
12 changes: 10 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,15 @@
mirrormode => $mirrormode,
multiprovider => $multiprovider,
syncusesubentry => $syncusesubentry,
syncrepl => $syncrepl,
syncrepl => $syncrepl.map |$item| {
$item.map |$k, $v| {
$v ? {
true => $k,
false => undef,
default => "${k}=${String($v, '%#p')}",
}
}.flatten.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
16 changes: 14 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,10 @@
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
Expand Down
46 changes: 46 additions & 0 deletions types/syncrepl.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# @summary Parameters for database replication consumers
#
# @see https://www.openldap.org/doc/admin26/slapdconfig.html#syncrepl
type Openldap::Syncrepl = Struct[
{
rid => Variant[Integer[0, 999], Pattern['\A\d{1,3}\z']],
provider => Pattern['\Aldaps?://[^/:]+(:\d+)?\z'],
searchbase => String[1],
Optional['type'] => Enum['refreshOnly', 'refreshAndPersist'],
Optional[interval] => Pattern['\A\d{2}:\d{2}:\d{2}:\d{2}\z'],
Optional[retry] => String[1],
Optional[filter] => String[1],
Optional[scope] => Enum['sub', 'one','base'],
Optional[attrs] => String[1],
Optional[exattrs] => String[1],
Optional[attrsonly] => Boolean,
Optional[sizelimit] => Integer[0],
Optional[timelimit] => Integer[0],
Optional[schemachecking] => Enum['on', 'off'],
Optional[network-timeout] => Integer[0],
Optional[timeout] => Integer[0],
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],
Optional[keepalive] => Pattern['\A\d{2}:\d{2}:\d{2}\z'],
Optional[starttls] => Enum['yes', 'critical'],
Optional[tls_cert] => Stdlib::Absolutepath,
Optional[tls_key] => Stdlib::Absolutepath,
Optional[tls_cacert] => Stdlib::Absolutepath,
Optional[tls_cacertdir] => Stdlib::Absolutepath,
Optional[tls_reqcert] => Enum['never', 'allow', 'try', 'demand'],
Optional[tls_cipher_suite] => String[1],
Optional[tls_crlcheck] => Enum['none', 'peer', 'all'],
Optional[tls_protocol_min] => Pattern['\A\d+(\.\d+)?\z'],
Optional[suffixmassage] => String[1],
Optional[logbase] => String[1],
Optional[logfilter] => String[1],
Optional[syncdata] => Enum['default', 'accesslog', 'changelog'],
}
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but a couple options are missing:

Optional[logbase] => String[1],
Optional[logfilter] => String[1],
Optional[retry] => String[1],
Optional[syncdata] => String[1],
Optional[sizeLimit] => Variant[Integer[0], Enum['unlimited']],
Optional[timelimit] => Variant[Integer[0], Enum['unlimited']],

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a PR against this branch with the missing fields I found

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Do you think this interface is better and we should go this way?

Loading