diff --git a/dovecot/manifests/init.pp b/dovecot/manifests/init.pp new file mode 100644 index 0000000..ea2e5ff --- /dev/null +++ b/dovecot/manifests/init.pp @@ -0,0 +1,83 @@ +class dovecot::common { + + case $operatingsystem { + centos,fedora: { + package { ["dovecot"]: + ensure => installed, + } + } + default: { + fail("Dovecot module not supported in ${operatingsystem}.") + } + } +} + +define dovecot::server($mx_mailname="", $ssl_csr="", $ssl_cert="", $ssl_key="", $ssl_chain="") { + + case $operatingsystem { + centos,fedora: { + $ssl_dir = "/etc/pki/tls" + } + default: { + fail("Dovecot module not supported in ${operatingsystem}.") + } + } + + service { "dovecot": + ensure => running, + enable => true, + require => File["/etc/dovecot.conf"], + } + + $mail_domain = $name ? { + "default" => "${homename}", + default => "${name}", + } + + if $ssl_chain { + file { "$ssl_dir/certs/${mx_mailname}.chain.crt": + ensure => present, + source => $ssl_chain, + mode => 0644, + owner => root, + group => root, + notify => Service["dovecot"], + } + } + + if $ssl_cert { + file { "$ssl_dir/certs/${mx_mailname}.crt": + ensure => present, + source => $ssl_cert, + mode => 0644, + owner => root, + group => root, + notify => Service["dovecot"], + } + } else { + fail("You need to define an ssl_cert in your node manifest.") + } + + if $ssl_key { + file { "$ssl_dir/private/${mx_mailname}.key": + ensure => present, + source => $ssl_key, + mode => 0600, + owner => root, + group => root, + notify => Service["dovecot"], + } + } else { + fail("You need to define an ssl_key in your node manifest.") + } + + file { "/etc/dovecot.conf": + ensure => present, + content => template("dovecot/dovecot.conf.erb"), + mode => 0644, + owner => root, + group => root, + notify => Service["dovecot"], + } + +} diff --git a/dovecot/templates/dovecot.conf.erb b/dovecot/templates/dovecot.conf.erb new file mode 100644 index 0000000..ed2bd16 --- /dev/null +++ b/dovecot/templates/dovecot.conf.erb @@ -0,0 +1,34 @@ +protocols = imaps +disable_plaintext_auth = yes +ssl_cert_file = <%= ssl_dir %>/certs/<%= mx_mailname %>.crt +ssl_key_file = <%= ssl_dir %>/private/<%= mx_mailname %>.key +ssl_ca_file = <%= ssl_dir %>/certs/<%= mx_mailname %>.chain.crt +login_chroot = yes +login_user = dovecot +login_max_processes_count = 256 +namespace private { + prefix = + location = mbox:~/imapmail/:INBOX=/var/mail/%u + inbox = yes +} +protocol imap { + mail_plugins = zlib +} + +protocol pop3 { +} +protocol lda { + postmaster_address = postmaster@<%= mail_domain %> +} +auth default { + mechanisms = plain + passdb pam { + } + userdb passwd { + } + user = root +} +dict { +} +plugin { +}