Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
- Puppet >= 6.0.0 < 9.0.0
- FreeBSD , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'markt-dovecot', '4.2.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-dovecot
Table of Contents
Description
This module installs and manages the dovecot imap server and its plugins, and provides resources and functions to configure the dovecot system. It does, however, not configure any of those systems beyond the upstream defaults.
This module is intended to work with Puppet 5 and 6, tested dovceot and OS versions are listed below. Patches to support other setups are welcome.
Usage
What this module affects
By default, this module...
- installs the dovecot package
- recursively purges all dovecot config files
Configuration options
While on a puppet-managed host, splitting the config into multiple conf.d files provides not much advantage, this module supports managing both the dovecot.conf file and several conf.d files.
The dovecot class takes two parameters, $config for dovecot.conf entries and $configs for conf.d file entries:
class { 'dovecot':
plugins => ['imap', 'lmtp'],
config => {
protocols => 'imap lmtp',
listen => '*, ::',
},
configs => {
'10-auth' => {
passdb => {
driver => 'passwd-file',
args => 'username_format=%u /etc/dovecot/virtual_accounts_passwd',
},
},
'10-logging' => {
log_path => 'syslog',
},
}
}
This can be conveniently used from hiera:
dovecot::plugins:
- imap
- lmtp
- sieve
dovecot::config:
protocols: imap sieve lmtp
hostname: "%{::fqdn}"
dovecot::configs:
'10-auth':
disable_plaintext_auth: yes
passdb:
driver: passwd-file
args: scheme=CRYPT username_format=%u /etc/dovecot/virtual_accounts_passwd
'10-master':
default_process_limit: 200
default_client_limit: 2000
service lmtp:
unix_listener /var/spool/postfix/private/dovecot-lmtp:
user: postfix
group: postfix
mode: '0600'
'10-ssl':
ssl: yes
ssl_cert: '</etc/dovecot/ssl/dovecot.crt'
ssl_key: '</etc/dovecot/ssl/dovecot.key'
For advanced use-cases you can also use the provided dovecot::create_config_resources
and
dovecot::create_config_file_resources
functions, that are used to handle the $config and
$configs parameters.
If you want to use the dovecot::config resource directly, the easiest way is to put both the file (optional) and the hierachical config key into the resource title:
dovecot::config {
'protocols': value => 'imap lmtp';
'listen':
value => '*, ::',
comment => 'Listen on all interfaces',
;
'10-auth:passdb.driver': value => 'passwd-file';
'10-auth:passdb.args': value => 'username_format=%u /etc/dovecot/virtual_accounts_passwd'
}
But you can also specify them separately:
dovecot::config { 'dovecot passdb driver':
file => '10-auth',
sections => ['passdb'],
key => 'driver',
value => 'passwd-file',
}
By default all regular config files are created with mode 0644, but this can be changed by
creating the dovecot::configfile
instance manually and specifying the $mode
param, or
by setting the global dovecot::configs_mode
parameter/hiera key.
External config files
In some cases, dovecot requires an external config file to be passed as a config value. This is especially the case for SQL- and LDAP-based userdbs.
These external config files are using a similar syntax, but are parsed by a different parser (and at a different point of time), as explained in the Dovecot wiki.
This module supports such external config files using the dovecot::extconfigfile
type, or
the dovecot::extconfigs
parameter/hiera key:
dovecot::configs:
'10-auth':
passdb:
driver: sql
args: /etc/dovecot/dovecot-sql.conf.ext
dovecot::extconfigs:
'dovecot-sql.conf.ext':
driver: pgsql
connect: host=sql.example.com dbname=virtual user=virtual password=blarg
default_pass_scheme: SHA256-CRYPT
password_query: "SELECT email as user, password FROM virtual_users WHERE email='%u';"
Since external config files often contain sensitive information like database passwords, they
are set to mode 0600 by default. This can be changed using the type's $mode
parameter, or
the global dovecot::extconfigs_mode
parameter/hiera key.
If you need to specify additional content in the file, like dict maps, you can use the
extended notation that takes an entries
and an additional_content
key:
dovecot::extconfigs:
'dovecot-dict-sql.conf.ext':
entries:
connect: host=localhost dbname=mails user=sqluser password=sqlpass
additional_content: |+
map {
pattern = shared/shared-boxes/user/$to/$from
table = user_shares
value_field = dummy
fields {
from_user = $from
to_user = $to
}
}
NOTE: These external config files are usually stored in /etc/dovecot
. Unfortunately,
the example-config delivered with Dovecot also contains .conf.ext
files in conf.d/
, which
are !included from 10-auth.conf
. Please note that these are not external config files as
explained here, they are included and parsed by the normal config parser. The example config
splits them out to provide multiple options the user can easily choose one from. In a
puppet-based setup, this should not be necessary, and is thus currently not supported by this
module. Please provide a valid use-case as a bug report, if you have one.
Poolmon configuration
For multi-server setups it is possible to enable built-in support for Poolmon:
dovecot::poolmon_manage: true
dovecot::poolmon_version: '0.6'
dovecot::poolmon_config:
scan_interval: 30
check_timeout: 5
log_debug: false
logfile: 'syslog'
check_port:
- 110
- 143
check_ssl:
- 993
socket: '/var/run/dovecot/director-admin'
lockfile: '/var/run/poolmon.pid'
NOTE: $dovecot::poolmon_config
uses "hash" merge behavior during lookup
(see Merge behavior below).
Reference
Classes and parameters are documented in REFERENCE.md.
Merge behavior
Although this module defaults to "deep" merge behavior for lookups, there's one notable exception.
The poolmon configuration $dovecot::poolmon_config
utilizes the "hash" merge behavior. This way
it is possible to replace default values when necessary, i.e. the check_port
item.
Development
Contributing
Please use the GitHub issues functionality to report any bugs or requests for new features. Feel free to fork and submit pull requests for potential contributions.
Reference
Table of Contents
Classes
Public Classes
dovecot
: This class allows simple configuration of the dovecot server.
Private Classes
dovecot::configuration
: This class handles dovecot configuration.dovecot::install
: This class handles packages.dovecot::poolmon
: Installs and configures Poolmon.dovecot::service
: This class handles services.
Defined types
dovecot::config
: This type manages a single config entry.dovecot::configentry
: Manages a single dovecot config entry.dovecot::configfile
: Manages a single dovecot config filedovecot::extconfigfile
: Resource for external config files providing a very basic key-value interface.dovecot::file
: Simple file resource that notifies the dovecot service.dovecot::sieve
: Simple sieve script resource that gets compiled by sievec and
Functions
dovecot::create_config_file_resources
: create {dovecot::config} resources from a nested hash (e.g. from hiera)dovecot::create_config_resources
: create dovecot::config resources from a nested hash (e.g. from hiera)dovecot::create_extconfigfile_resources
: create {dovecot::extconfigfile} resources from a nested hash (e.g. from hiera)dovecot::print_config_value
: returns a properly quoted dovecot config value
Classes
dovecot
There is no semantic abstraction done in this class, all config parameters are passed directly to dovecot via config files.
Examples
Using a profile to load merged values from hiera:
$config = hiera_hash("${title}::config", {})
$configs = hiera_hash("${title}::configs", {})
$plugins = hiera_array("${title}::plugins", undef)
class { 'dovecot':
plugins => $plugins,
config => $config,
configs => $configs,
}
Parameters
The following parameters are available in the dovecot
class:
config
config_path
configs
configs_mode
directory_private_manage
extconfigs
extconfigs_mode
package_ensure
package_manage
package_name
plugin
plugins
poolmon_archive_params
poolmon_basepath
poolmon_config
poolmon_config_file
poolmon_exec
poolmon_manage
poolmon_service_enable
poolmon_service_ensure
poolmon_service_file
poolmon_service_mode
poolmon_service_provider
poolmon_version
purge_unmanaged
service_enable
service_ensure
service_manage
service_name
sievec
config
Data type: Hash
A hash of config file entries, with nested hashes parsed as sections.
config_path
Data type: String
The path to the dovecot config dir.
configs
Data type: Hash
A hash of conf.d file names to $config-style hashes.
configs_mode
Data type: String
The file permissions that should be applied.
directory_private_manage
Data type: Boolean
Whether to manage the private directory.
extconfigs
Data type: Hash
A hash of external config files.
extconfigs_mode
Data type: String
The file permissions that should be applied.
package_ensure
Data type: String
Whether to install the dovecot package, and what version to install. Values: 'present', 'latest', or a specific version number. Default value: 'present'.
package_manage
Data type: Boolean
Whether to install the dovecot core and plugin packages.
package_name
Data type: Array[String]
The name of the main dovecot package.
plugin
Data type: Hash
Contains a package_name parameter for each plugin (if available).
plugins
Data type: Array[String[1]]
The list of plugins to install.
poolmon_archive_params
Data type: Hash
Additional parameters that should be passed through to the archive
resource.
poolmon_basepath
Data type: String
The base path for installing poolmon.
poolmon_config
Data type: Hash
A list of config options.
poolmon_config_file
Data type: String
The path and filename of the configuration file.
poolmon_exec
Data type: String
The path to the poolmon binary.
poolmon_manage
Data type: Boolean
Whether to manage the poolmon service. Default value: false.
poolmon_service_enable
Data type: Boolean
Whether the poolmon service should be configured for automatic startup.
poolmon_service_ensure
Data type: Enum['running', 'stopped']
The desired state for the service.
poolmon_service_file
Data type: String
The path to the service file.
poolmon_service_mode
Data type: String
File permissions for the service file.
poolmon_service_provider
Data type: Enum['init', 'rc', 'systemd']
The provider used to handle services, e.g. systemd.
poolmon_version
Data type: String
The version of poolmon that should be installed.
purge_unmanaged
Data type: Boolean
Whether to purge all unmanaged files in the dovecot directory.
service_enable
Data type: Boolean
Whether to enable the dovecot service at boot. Default value: true.
service_ensure
Data type: Enum['running', 'stopped']
Whether the dovecot service should be running. Default value: 'running'.
service_manage
Data type: Boolean
Whether to manage the dovecot service.
service_name
Data type: String
The dovecot service to manage. Default value: varies by operating system.
sievec
Data type: Stdlib::Absolutepath
The path to the sievec binary.
Defined types
dovecot::config
Dovecot uses its own config format. This format basically allows to define a hierarchy of configuration sections (and syntactically identical filters, so they will just be treated as sections by this module).
Since in puppet, we want to map each single config entry as its own resource, the hierarchy has been "flattened" to hierarchical keys.
A key/value pair foo = bar
nested in a section
object, would look like
this in a dovecot config file:
section {
foo = bar
}
To reference this key in a dovecot::config variable, you would use the
notation section.foo
.
Title/Name format
This module can manage both a global dovecot.conf and single conf.d files. The module author recommends single file setups for puppet-managed hosts, but users can choose to split their managed config into single files.
To specify which file a config entry should got to, you can use the file
parameter.
For convenience reasons, however, this resource also allows to encode the values for $sections, $key, and $file into the resource's name (which is usally the same as its title).
If the $name of the resource matches the format "[:][<sections>.]", and all of $file, $sections, and $key have not been specified, the values from the name are used. This simplifies creating unique resources for identical settings in different files.
Parameters
The following parameters are available in the dovecot::config
defined type:
sections
Data type: Optional[Array[String]]
An array of section names that define the hierarchical name of this key.
E.g. ["protocol imap", "plugin"] to denote the
protocol imap { plugin {` section.
Default value: undef
key
Data type: Optional[String]
The key name of the config setting. The key is expected as a single non-hierachical
name without any sections/filters.
The special values !include
and !include_try
can be used for includes.
Default value: undef
file
Data type: Optional[String]
The file to put the value in. If undef (the default), the value is put into the
global dovecot.conf, otherwise the value si written to conf.d/${file}.conf
The value of this parameter must not include any path information or file extension.
E.g. 10-auth
Default value: undef
value
Data type: Variant[Boolean, Integer, String]
the value of this config entry.
comment
Data type: Optional[String]
an optional comment that will be written to the config file above the entry
Default value: undef
ensure
Data type: Enum['present', 'absent']
whether this entry should be present
or absent
. Usually not needed at all,
because the config file will be fully managed by puppet and re-created each time.
Default value: 'present'
dovecot::configentry
Manages a single dovecot config entry.
-
Note This class is only for internal use, use dovecot::config instead.
-
See also
- dovecot::config
Parameters
The following parameters are available in the dovecot::configentry
defined type:
comment
Data type: Optional[String]
an optional comment to be printed above the entry
Default value: undef
ensure
Data type: Enum['present', 'absent']
Whether the entry should be present
or absent
.
Default value: 'present'
file
Data type: Stdlib::Absolutepath
The file to put the entry in.
key
Data type: String
The entry's key, or !include/!include_try.
sections
Data type: Array[String]
The entry's sections as an array.
Default value: []
value
Data type: Variant[Boolean, Integer, String]
The entry's value.
dovecot::configfile
Manages a single dovecot config file
-
Note This define is only for internal use, use dovecot::config instead.
-
See also
- dovecot::config
Parameters
The following parameters are available in the dovecot::configfile
defined type:
comment
Data type: Optional[String]
An optional comment to be printed at the top of the file instead of the default warning.
Default value: undef
ensure
Data type: Enum['present', 'absent']
Whether the file should be present
or absent
.
Default value: 'present'
file
Data type: Stdlib::Absolutepath
The file to put the entry in.
Default value: $title
group
Data type: Variant[Integer, String]
The group that should own the file.
Default value: 0
mode
Data type: Variant[Integer, String]
The permissions for the file.
Default value: $dovecot::configs_mode
owner
Data type: Variant[Integer, String]
The user that should own the file.
Default value: 'root'
dovecot::extconfigfile
Resource for external config files providing a very basic key-value interface.
Parameters
The following parameters are available in the dovecot::extconfigfile
defined type:
additional_content
Data type: Optional[String]
Additional content for the file.
Default value: undef
entries
Data type: Hash[String, String]
A hash of string=string entries. All values will be written as-is to the file, any escaping must already be applied.
group
Data type: Variant[Integer, String]
The group that should own the file.
Default value: 0
mode
Data type: Variant[Integer, String]
The permissions for the file.
Default value: $dovecot::extconfigs_mode
owner
Data type: Variant[Integer, String]
The user that should own the file.
Default value: 'root'
relpath
Data type: String
The path of the external config file relative to dovecot::config_path, including the desired extension. Defaults to the resource title.
Default value: $title
warn
Data type: Variant[Boolean, String]
Whether to prepend the default warning (if true
), a
custom warning (if a String
), or nothing at all.
Default value: true
dovecot::file
Simple file resource that notifies the dovecot service.
Parameters
The following parameters are available in the dovecot::file
defined type:
content
Data type: String
The content of the file.
group
Data type: Variant[Integer, String]
The group that should own the file.
Default value: 0
mode
Data type: Variant[Integer, String]
The permissions for the file.
Default value: '0644'
owner
Data type: Variant[Integer, String]
The user that should own the file.
Default value: 'root'
path
Data type: Stdlib::Absolutepath
The target path for the file.
dovecot::sieve
notifies the dovecot service.
Parameters
The following parameters are available in the dovecot::sieve
defined type:
content
Data type: String
The content of the file.
Default value: undef
group
Data type: Variant[Integer, String]
The group that should own the file.
Default value: 0
mode
Data type: Variant[Integer, String]
The permissions for the file.
Default value: '0644'
owner
Data type: Variant[Integer, String]
The user that should own the file.
Default value: 'root'
path
Data type: Stdlib::Absolutepath
The target path for the file.
Default value: $name
sievec
Data type: Stdlib::Absolutepath
The path to the sievec binary.
Default value: $dovecot::sievec
source
Data type: Optional[String]
Optional source for the file resource to use instead of $content
.
Default value: undef
Functions
dovecot::create_config_file_resources
Type: Puppet Language
Function: dovecot::create_config_file_resources()
Create {dovecot::config} resources from a nested hash, suitable for conveniently loading values from hiera.
The first level of keys is the config files to be written to, the values being the hierarchical values that will be passed to the {dovecot::create_config_resources} function
dovecot::create_config_file_resources(Hash[String, Hash] $configfile_hash, Boolean $include_in_main_config = true, Hash $params = {})
Function: dovecot::create_config_file_resources()
Create {dovecot::config} resources from a nested hash, suitable for conveniently loading values from hiera.
The first level of keys is the config files to be written to, the values being the hierarchical values that will be passed to the {dovecot::create_config_resources} function
Returns: Any
configfile_hash
Data type: Hash[String, Hash]
a hash of config file names mapped to config hashes
include_in_main_config
Data type: Boolean
whether the single config files should be included from dovecot.conf
params
Data type: Hash
a hash of params passed to the {dovecot::config} resource (:file will be overridden)
dovecot::create_config_resources
Type: Puppet Language
Create dovecot::config resources from a nested hash, suitable for conveniently loading values from hiera. The key-value pairs from the hash represent config keys and values passed to dovecot::config for simple values, Hash values recursively create nested sections, and Array values are joined with spaces.
dovecot::create_config_resources(Hash[String, NotUndef] $config_hash, Hash $params = {}, Array[String] $sections = [])
Create dovecot::config resources from a nested hash, suitable for conveniently loading values from hiera. The key-value pairs from the hash represent config keys and values passed to dovecot::config for simple values, Hash values recursively create nested sections, and Array values are joined with spaces.
Returns: Any
config_hash
Data type: Hash[String, NotUndef]
a hash of (non-hierarchical) key names mapped to values
params
Data type: Hash
a hash of params passed to dovecot::config (must not include :sections, :key, or :value)
sections
Data type: Array[String]
the section names of the hierarchical key, will usually only be specified on recursive calls from within this function itself
dovecot::create_extconfigfile_resources
Type: Puppet Language
Function: dovecot::create_extconfigfile_resources()
Create {dovecot::extconfigfile} resources from a nested hash, suitable for conveniently loading values from hiera.
The first level of keys is the config files to be written to, the values being the hierarchical values that will be passed to the extconfigfile resource.
Values can either be a Hash[String, String], or a hash containing two properties
entries
and additional_content
.
dovecot::create_extconfigfile_resources(Hash[String, Hash] $configfile_hash)
Function: dovecot::create_extconfigfile_resources()
Create {dovecot::extconfigfile} resources from a nested hash, suitable for conveniently loading values from hiera.
The first level of keys is the config files to be written to, the values being the hierarchical values that will be passed to the extconfigfile resource.
Values can either be a Hash[String, String], or a hash containing two properties
entries
and additional_content
.
Returns: Any
configfile_hash
Data type: Hash[String, Hash]
a hash of config file names mapped to config hashes
dovecot::print_config_value
Type: Puppet Language
Function: dovecot::print_config_value()
dovecot::print_config_value(Any $value)
Function: dovecot::print_config_value()
Returns: Any
the formatted config value suitable for inclusion in a dovecot config file
value
Data type: Any
the value to be printed
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
4.2.0 - 2024-03-13
Changed
4.1.0 - 2023-08-08
Added
- Add
$sievec
parameter to main class
Changed
- Replace bad
lookup()
pattern with new$dovecot::sievec
parameter - Update module dependencies
- Update to PDK 3.0.0
4.0.0 - 2023-05-16
Added
- Enable GitHub Actions
- Add basic acceptance test
Changed
- Purge directories recursively (#29)
- Update PDK to 2.7.1 (#31)
- Bump OS and Puppet dependencies
- Minor improvement to unit test
Fixes
- Frequent service restarts because directories cannot be purged (#29)
- Unknown variables in poolmon config (#30)
3.1.0 - 2020-09-12
This release now uses PDK and increases dependency compatibility.
Changed
- Increased compatible stdlib dependency versions in metadata (#25)
- Convert to PDK
3.0.0 - 2020-04-07
This release modifies the behaviour of purge_unmanaged
parameter to include
files in "conf.d" and "private" directories.
While in theory this is a breaking change (hence the version increase), it
should rarely have any real effects. In any case, be advised that unmanaged
files in conf.d and private directories will be purged if you have
purge_unmanaged
enabled (which it is by default).
Changed
purge_unmanaged
now also purges "conf.d" and "private" directories (#22)
2.3.0 - 2020-04-07
This release solely changes documentation and metadata.
Changed
- Increased compatible dependency versions in metadata (#23)
2.2.0 - 2020-03-20
This release adds support for additional content in extconfig files.
Added
- Add support for additional content in extconfig files (#19)
2.1.0 - 2019-03-23
This release solely changes documentation and metadata.
Changed
2.0.0 - 2019-02-04
This release includes one breaking change, the switch to "hash" merge behaviour
for $dovecot::poolmon_config
. This will most likely not affect your
configuration, but in theory it might, so this is released as a new major
version in conformance with SemVer.
Changed
$dovecot::poolmon_config
now uses "hash" merge behaviour (#13).
1.2.0 - 2018-12-10
This release mainly fixes and improves poolmon service management
Added
- Manage /etc/dovecot/private directory (if enabled, default on Debian-based systems), to prevent log noise and service notifies after package updates
- Add SysVinit support for poolmon service (#12)
Fixes
- Fix poolmon systemd service generation (#12)
1.1.0 - 2018-06-02
This release adds support for managing external config files
Added
- Support for external config files as required for some userdb/passdb drivers (#6)
- Make config files mode configurable
Fixes
- Fixed
dovecot::create_config_file_resources()
not respecting$include_in_main_config
(#8)
1.0.1 - 2018-01-28
This release only contains minor non-functional and documentation changes
Fixes
- Fix links in this changelog
- Lint fixes
1.0.0 - 2018-01-28
First stable release, now requires Puppet 4.9
Added
- Support support for other operating systems (RedHat, Debian and FreeBSD)
- New parameters for service configuration (
$service_enable
,$service_ensure
,$service_name
to customize the service name,$package_ensure
to allow 'latest' or a specific version number) - Add poolmon support
Changed
- Minium required puppet version is now 4.9 for Hiera 5 support
- Module structure has been completely rewritten, uses standard module layout now
- Rename parameter
$packages_install
to$package_manage
- Lots of lint/style changes
Fixed
require
on service would fail if$package_manage
wasfalse
0.1.0 - 2017-07-31
Initial release
Dependencies
- puppetlabs/stdlib (>= 8.0.0 < 10.0.0)
- puppetlabs/concat (>= 7.0.0 < 10.0.0)
- puppet/archive (>= 6.0.0 < 8.0.0)
Copyright 2023 Frank Wall Copyright 2017 Bernhard Frauendienst Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.