summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2014-02-25 15:43:42 +0100
committervarac <varacanero@zeromail.org>2014-02-25 15:43:42 +0100
commitc2539d1ea132e137d29f3183e7aac568462865b0 (patch)
treeaa71997081abe88e95fd07d8e532ce8afbcf7cea
parent705fd0a13dc4d2f073819947159e28b54c286550 (diff)
parent34333c48ba5662228c37a70eb099ec9a5f96b5ac (diff)
Merge branch 'leap_master'
Conflicts: files/munin/dovecot manifests/base.pp manifests/centos.pp manifests/debian.pp manifests/expire.pp manifests/init.pp manifests/munin.pp manifests/quota.pp manifests/sieve.pp manifests/sql.pp
-rw-r--r--files/expire/mysql-dict-expire.conf12
-rw-r--r--files/munin/dovecot71
-rw-r--r--files/sieve/after.sieve5
-rw-r--r--files/sieve/before.sieve1
-rw-r--r--manifests/base.pp45
-rw-r--r--manifests/centos.pp3
-rw-r--r--manifests/config/file.pp76
-rw-r--r--manifests/debian.pp9
-rw-r--r--manifests/deliver.pp4
-rw-r--r--manifests/expire.pp59
-rw-r--r--manifests/expire/mysql.pp20
-rw-r--r--manifests/expire/sqlite.pp29
-rw-r--r--manifests/init.pp15
-rw-r--r--manifests/logrotate.pp6
-rw-r--r--manifests/managesieve.pp10
-rw-r--r--manifests/munin.pp9
-rw-r--r--manifests/quota.pp1
-rw-r--r--manifests/sieve.pp73
-rw-r--r--manifests/sql.pp21
-rw-r--r--manifests/sql/mysql.pp9
-rw-r--r--manifests/sql/pgsql.pp9
-rw-r--r--manifests/sql/sqlite.pp9
22 files changed, 350 insertions, 146 deletions
diff --git a/files/expire/mysql-dict-expire.conf b/files/expire/mysql-dict-expire.conf
new file mode 100644
index 0000000..ecf3cc8
--- /dev/null
+++ b/files/expire/mysql-dict-expire.conf
@@ -0,0 +1,12 @@
+connect = host=localhost dbname=mails user=sqluser password=sqlpass
+
+map {
+ pattern = shared/expire/$user/$mailbox
+ table = expires
+ value_field = expire_stamp
+
+ fields {
+ username = $user
+ mailbox = $mailbox
+ }
+} \ No newline at end of file
diff --git a/files/munin/dovecot b/files/munin/dovecot
index 1f9e3b4..86feb4b 100644
--- a/files/munin/dovecot
+++ b/files/munin/dovecot
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Munin Plugin
# to count logins to your dovecot mailserver
@@ -28,7 +28,7 @@
######################
# Configuration
######################
-STAT_FILE=${STAT_FILE:-/var/lib/munin/plugin-state/plugin-dovecot.state}
+STAT_FILE=/var/lib/munin/plugin-state/plugin-dovecot.state
EXPR_BIN=/usr/bin/expr
LOGFILE=${logfile:-/var/log/mail.log}
######################
@@ -47,8 +47,6 @@ if [ "$1" = "config" ]; then
echo 'login_ssl.label SSL Logins'
echo 'login_imap.label IMAP Logins'
echo 'login_pop3.label POP3 Logins'
- echo 'login_imap_proxy.label IMAP Proxy Logins'
- echo 'login_pop3_proxy.label POP3 Proxy Logins'
echo 'connected.label Connected Users'
exit 0
fi
@@ -62,8 +60,6 @@ if [ ! -r $STAT_FILE ]; then
echo "SSL=0" >> $STAT_FILE
echo "IMAP=0" >> $STAT_FILE
echo "POP3=0" >> $STAT_FILE
- echo "IMAP_PROXY=0" >> $STAT_FILE
- echo "POP3_PROXY=0" >> $STAT_FILE
fi
#############################
@@ -71,8 +67,8 @@ fi
######################
# Total Logins
######################
-echo -en "login_total.value "
-NEW_TOTAL=$(egrep '[dovecot]?.*(Login|started proxying)' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
+/bin/echo -en "login_total.value "
+NEW_TOTAL=$(egrep 'dovecot.*Login' $LOGFILE | grep "`date '+%b %e'`" | sort | wc -l)
OLD_TOTAL=$(grep TOTAL $STAT_FILE | cut -f2 -d '=')
TOTAL=$($EXPR_BIN $NEW_TOTAL - $OLD_TOTAL)
if [ $TOTAL -gt 0 ]; then
@@ -84,20 +80,15 @@ echo -n
######################
# Connected Users
######################
-DISCONNECTS=$(egrep '[dovecot]?.*(Disconnected|Connection closed|disconnecting)' $LOGFILE | sort | wc -l)
-CONNECTS=$(egrep '[dovecot]?.*(Login|started proxying)' $LOGFILE | sort | wc -l)
-DISCON=$($EXPR_BIN $CONNECTS - $DISCONNECTS)
-if [ $DISCON -lt 0 ]; then
- DISCON=0
-fi
-echo -en "connected.value "
-echo $DISCON
+CONNECTS=$(doveadm -f flow who -1 |wc -l)
+/bin/echo -en "connected.value "
+echo $CONNECTS
echo -n
######################
# TLS Logins
######################
-echo -en "login_tls.value "
-NEW_TLS=$(egrep '[dovecot]?.*Login.*TLS' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
+/bin/echo -en "login_tls.value "
+NEW_TLS=$(egrep 'dovecot.*Login.*TLS' $LOGFILE | grep "`date '+%b %e'`" | sort | wc -l)
OLD_TLS=$(grep TLS $STAT_FILE | cut -f2 -d '=')
TLS=$($EXPR_BIN $NEW_TLS - $OLD_TLS)
if [ $TLS -gt 0 ]; then
@@ -109,8 +100,8 @@ echo -n
######################
# SSL Logins
######################
-echo -en "login_ssl.value "
-NEW_SSL=$(egrep '[dovecot]?.*Login.*SSL' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
+/bin/echo -en "login_ssl.value "
+NEW_SSL=$(egrep 'dovecot.*Login.*SSL' $LOGFILE | grep "`date '+%b %e'`" | sort | wc -l)
OLD_SSL=$(grep SSL $STAT_FILE | cut -f2 -d '=')
SSL=$($EXPR_BIN $NEW_SSL - $OLD_SSL)
if [ $SSL -gt 0 ]; then
@@ -122,9 +113,9 @@ echo -n
######################
# IMAP Logins
######################
-echo -en "login_imap.value "
-NEW_IMAP=$(egrep '[dovecot]?.*imap.*Login' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
-OLD_IMAP=$(grep 'IMAP=' $STAT_FILE | cut -f2 -d '=')
+/bin/echo -en "login_imap.value "
+NEW_IMAP=$(egrep 'dovecot.*imap.*Login' $LOGFILE | grep "`date '+%b %e'`" | sort | wc -l)
+OLD_IMAP=$(grep IMAP $STAT_FILE | cut -f2 -d '=')
IMAP=$($EXPR_BIN $NEW_IMAP - $OLD_IMAP)
if [ $IMAP -gt 0 ]; then
echo "$IMAP"
@@ -135,9 +126,9 @@ echo -n
######################
# POP3 Logins
######################
-echo -en "login_pop3.value "
-NEW_POP3=$(egrep '[dovecot]?.*pop3.*Login' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
-OLD_POP3=$(grep 'POP3=' $STAT_FILE | cut -f2 -d '=')
+/bin/echo -en "login_pop3.value "
+NEW_POP3=$(egrep 'dovecot.*pop3.*Login' $LOGFILE | grep "`date '+%b %e'`" | sort | wc -l)
+OLD_POP3=$(grep POP3 $STAT_FILE | cut -f2 -d '=')
POP3=$($EXPR_BIN $NEW_POP3 - $OLD_POP3)
if [ $POP3 -gt 0 ]; then
echo "$POP3"
@@ -146,32 +137,6 @@ else
fi
echo -n
######################
-# POP3 Proxy Logins
-######################
-echo -en "login_pop3_proxy.value "
-NEW_POP3_PROXY=$(egrep '[dovecot]?.*pop3.*started proxying' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
-OLD_POP3_PROXY=$(grep POP3_PROXY $STAT_FILE | cut -f2 -d '=')
-POP3_PROXY=$($EXPR_BIN $NEW_POP3_PROXY - $OLD_POP3_PROXY)
-if [ $POP3_PROXY -gt 0 ]; then
- echo "$POP3_PROXY"
-else
- echo "0"
-fi
-echo -n
-######################
-# IMAP Proxy Logins
-######################
-echo -en "login_imap_proxy.value "
-NEW_IMAP_PROXY=$(egrep '[dovecot]?.*imap*started proxying' $LOGFILE | grep "`date '+%b %d'`" | sort | wc -l)
-OLD_IMAP_PROXY=$(grep IMAP_PROXY $STAT_FILE | cut -f2 -d '=')
-IMAP_PROXY=$($EXPR_BIN $NEW_IMAP_PROXY - $OLD_IMAP_PROXY)
-if [ $IMAP_PROXY -gt 0 ]; then
- echo "$IMAP_PROXY"
-else
- echo "0"
-fi
-echo -n
-######################
# Save the new values
######################
echo "TOTAL=$NEW_TOTAL" > $STAT_FILE
@@ -179,5 +144,3 @@ echo "TLS=$NEW_TLS" >> $STAT_FILE
echo "SSL=$NEW_SSL" >> $STAT_FILE
echo "IMAP=$NEW_IMAP" >> $STAT_FILE
echo "POP3=$NEW_POP3" >> $STAT_FILE
-echo "POP3_PROXY=$NEW_POP3_PROXY" >> $STAT_FILE
-echo "IMAP_PROXY=$NEW_IMAP_PROXY" >> $STAT_FILE
diff --git a/files/sieve/after.sieve b/files/sieve/after.sieve
new file mode 100644
index 0000000..610d0d1
--- /dev/null
+++ b/files/sieve/after.sieve
@@ -0,0 +1,5 @@
+# for sequential sieve scripts, this one is the after_sieve
+# keep is implicit, but it seems that only explicit fileinto actions
+# are logged and not the implicit keep action, so we specify it explicitly
+fileinto "INBOX";
+stop;
diff --git a/files/sieve/before.sieve b/files/sieve/before.sieve
new file mode 100644
index 0000000..4884529
--- /dev/null
+++ b/files/sieve/before.sieve
@@ -0,0 +1 @@
+# for sequential sieve scripts, this one is the before_sieve
diff --git a/manifests/base.pp b/manifests/base.pp
index 19cafbf..1cd9996 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -4,27 +4,48 @@ class dovecot::base {
}
file{'/etc/dovecot.conf':
- source => [ "puppet:///modules/site_dovecot/config/${::fqdn}/dovecot.conf",
- "puppet:///modules/site_dovecot/config/${dovecot::type}/dovecot.conf",
- "puppet:///modules/site_dovecot/config/dovecot.conf",
- "puppet:///modules/dovecot/config/${::operatingsystem}/dovecot.conf",
- "puppet:///modules/dovecot/config/dovecot.conf" ],
+ source => [ "puppet:///modules/site_dovecot/config/${::fqdn}/dovecot.conf",
+ "puppet:///modules/site_dovecot/config/${::dovecot::type}/dovecot.conf",
+ 'puppet:///modules/site_dovecot/config/dovecot.conf',
+ "puppet:///modules/dovecot/config/${::operatingsystem}/dovecot.conf",
+ 'puppet:///modules/dovecot/config/dovecot.conf' ],
require => Package['dovecot'],
notify => Service['dovecot'],
- owner => root, group => mail, mode => 0640;
+ owner => root,
+ group => mail,
+ mode => '0644';
}
- file{'/var/log/dovecot':
+ file { 'dovecot_config_dir':
ensure => directory,
+ path => '/etc/dovecot/conf.d',
require => Package['dovecot'],
- before => Service['dovecot'],
- owner => dovecot, group => 12, mode => 0660,
+ owner => dovecot,
+ group => 0,
+ mode => '0755';
}
- file{ [ '/var/log/dovecot/error.log',
- '/var/log/dovecot/infos.log' ]:
+
+ file {
+ '/var/log/dovecot':
+ ensure => directory,
require => Package['dovecot'],
before => Service['dovecot'],
- owner => root, group => 12, mode => 0660;
+ owner => dovecot,
+ group => dovecot,
+ mode => '0750';
+
+ [ '/var/log/dovecot/error.log',
+ '/var/log/dovecot/dovecot.log' ]:
+ require => Package['dovecot'],
+ before => Service['dovecot'],
+ owner => root,
+ group => dovecot,
+ mode => '0660';
+ }
+
+ package { 'dovecot':
+ ensure => installed,
+ alias => 'dovecot'
}
include dovecot::logrotate
diff --git a/manifests/centos.pp b/manifests/centos.pp
index 7e7eefa..34ccdbf 100644
--- a/manifests/centos.pp
+++ b/manifests/centos.pp
@@ -1,6 +1,7 @@
class dovecot::centos inherits dovecot::base {
+
file{'/etc/sysconfig/dovecot':
- source => [ "puppet:///modules/site_dovecot/sysconfig/${::fqdn}/dovecot",
+ source => [ "puppet:///modules/site_dovecot/sysconfig/${fqdn}/dovecot",
"puppet:///modules/site_dovecot/sysconfig/${dovecot::type}/dovecot",
"puppet:///modules/site_dovecot/sysconfig/dovecot",
"puppet:///modules/dovecot/sysconfig/dovecot" ],
diff --git a/manifests/config/file.pp b/manifests/config/file.pp
new file mode 100644
index 0000000..e6e93c3
--- /dev/null
+++ b/manifests/config/file.pp
@@ -0,0 +1,76 @@
+define dovecot::config::file (
+ $ensure = present,
+ $source = 'absent',
+ $content = 'absent',
+ $destination = 'absent',
+ $mode = 'absent',
+ $owner = 'absent',
+ $group = 'absent'
+)
+{
+
+ # the default destination is 'absent', so if the user doesn't specify a
+ # destination, then we use the following defaults. If different systems
+ # implement different locations, we can trigger here off of operatingsystem
+ # and change the 'dovecot_config_dir' path in base.pp to just be /etc/dovecot
+ $real_destination = $destination ? {
+ 'absent' => "/etc/dovecot/conf.d/${name}",
+ default => $destination
+ }
+
+ $real_mode = $mode ? {
+ 'absent' => 0640,
+ default => $mode
+ }
+
+ $real_owner = $owner ? {
+ 'absent' => root,
+ default => $owner
+ }
+
+ $real_group = $group ? {
+ 'absent' => 0,
+ default => $group
+ }
+
+ # the $name variable is set to dovecot_${name}, but the actual filename will
+ # be set to $name
+ file { "dovecot_${name}":
+ ensure => $ensure,
+ path => $real_destination,
+ notify => Service[dovecot],
+ owner => $real_owner, group => $real_group, mode => $real_mode;
+ }
+
+ # the $content variable is 'absent' by default, so if the user doesn't
+ # specify anything for $content, then the following will be used, searching
+ # from the first source line until a file is found that matches. We use the
+ # standard search prioritizing the site_dovecot module first
+ case $content {
+ 'absent': {
+ $real_source = $source ? {
+ 'absent' => [
+ "puppet:///modules/site_dovecot/config/${fqdn}/${name}",
+ "puppet:///modules/site_dovecot/config/${operatingsystem}/${lsbdistcodename}/${name}",
+ "puppet:///modules/site_dovecot/config/${operatingsystem}/${name}",
+ "puppet:///modules/site_dovecot/config/${name}",
+ "puppet:///modules/dovecot/config/${operatingsystem}/${lsbdistcodename}/${name}",
+ "puppet:///modules/dovecot/config/${operatingsystem}/${name}",
+ "puppet:///modules/dovecot/config/${name}"
+ ],
+ default => "puppet:///${source}",
+ }
+ File["dovecot_${name}"]{
+ source => $real_source,
+ }
+ }
+ default: {
+ File["dovecot_${name}"]{
+ content => $content,
+ }
+ }
+ }
+ File["dovecot_${name}"]{
+ require => Package[dovecot],
+ }
+}
diff --git a/manifests/debian.pp b/manifests/debian.pp
index dc41603..82ff579 100644
--- a/manifests/debian.pp
+++ b/manifests/debian.pp
@@ -1,5 +1,8 @@
class dovecot::debian inherits dovecot::base {
- Package['dovecot'] {
- name => 'dovecot-imapd'
- }
+
+ Package['dovecot'] { name => [ 'dovecot-common', 'dovecot-imapd', 'dovecot-pop3d' ] }
+
+ File['/etc/dovecot.conf'] { path => '/etc/dovecot/dovecot.conf' }
+
}
+
diff --git a/manifests/deliver.pp b/manifests/deliver.pp
index c501ebe..da190f1 100644
--- a/manifests/deliver.pp
+++ b/manifests/deliver.pp
@@ -1,6 +1,8 @@
class dovecot::deliver {
+
include ::dovecot
- file{ [ '/var/log/dovecot/deliver.log',
+
+ file { [ '/var/log/dovecot/deliver.log',
'/var/log/dovecot/deliver-error.log' ]:
require => Package['dovecot'],
before => Service['dovecot'],
diff --git a/manifests/expire.pp b/manifests/expire.pp
index 42a170c..7eb5c6a 100644
--- a/manifests/expire.pp
+++ b/manifests/expire.pp
@@ -1,32 +1,58 @@
-class dovecot::expire(
- $type = 'script',
- $mail_location = 'absent',
- $days = '14',
- $directories = 'Trash\|Junk'
-) {
- include ::dovecot
+class dovecot::expire ( $type = 'sqlite', $mail_location = '', $dirs = '', $days = '' ) {
file{'/etc/cron.daily/dovecot-expire':
owner => root, group => 0, mode => 0755;
}
- if $dovecot::expire::type == 'legacy' or $dovecot::expire::type == 'mixed' {
- case $dovecot::expire::mail_location {
- 'absent': { fail("Need to set \$mail_location on ${::fqdn}!") }
+
+ if $type == 'legacy' or $type == 'mixed' {
+ case $mail_location {
+ '': { fail("Need to set \$dovecot_mail_location on $fqdn!") }
+ }
+ case $dirs {
+ '': { $dirs = 'Trash\|Junk' }
+ }
+ case $days {
+ '': { $days = '14' }
}
File['/etc/cron.daily/dovecot-expire']{
- content => "find ${dovecot::expire::mail_location} -regex '.*/\\.\\(${dovecot::expire::directories}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${dovecot::expire::days} -delete\n"
+ content => "find ${mail_location} -regex '.*/\\.\\(${dirs}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${days} -delete\n"
}
} else {
+ # dovecot version 1 way
+ if $version != 2 {
+ case $operatingsystem {
+ debian: {
+ augeas { "expire_cron":
+ context => "/files/etc/default/dovecot/rule",
+ changes => [ 'set /files/etc/default/dovecot/EXPIRE_CRON \'"daily"\'' ],
+ }
+ }
+ default: {
File['/etc/cron.daily/dovecot-expire']{
content => "dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool.sh\n"
}
}
+ }
+ } else {
+ # dovecot version 2 way (no mail_location, dirs need to be space separated variables and expire script runs doveadm expunge)
+ # problem with this method is that it doesn't allow for different times for different mailboxes
+ case $dirs {
+ '': { $dirs = 'Trash Junk' }
+ }
+ case $days {
+ '': { $days = '14' }
+ }
+ File['/etc/cron.daily/dovecot-expire']{
+ content => "#!/bin/sh\n\n dirs='${dirs}'\nfor mailbox in \$dirs; do doveadm expunge -A mailbox \$mailbox savedbefore ${days}d; done\n"
+ }
+ }
+ }
- if $dovecot::expire::type != 'legacy' {
+ if $type != 'legacy' and $type != 'mysql' and $version != 2 {
file{'/etc/dovecot-expire.conf':
- source => [ "puppet:///modules/site_dovecot/expire/${::fqdn}/dovecot-expire.conf",
+ source => [ "puppet:///modules/site_dovecot/expire/${fqdn}/dovecot-expire.conf",
"puppet:///modules/site_dovecot/expire/dovecot-expire.conf",
- "puppet:///modules/dovecot/expire/${::operatingsystem}/dovecot-expire.conf",
+ "puppet:///modules/dovecot/expire/${operatingsystem}/dovecot-expire.conf",
"puppet:///modules/dovecot/expire/dovecot-expire.conf" ],
require => Package['dovecot'],
notify => Service['dovecot'],
@@ -39,9 +65,10 @@ class dovecot::expire(
}
}
- case $dovecot::expire::type {
- 'legacy': { info("no need to include anything for legacy type") }
+ case $type {
+ 'legacy': { info("no need to include anything for legacy mode") }
'mixed': { include ::dovecot::expire::sqlite }
+ 'mysql': { include ::dovecot::expire::mysql }
default: { include ::dovecot::expire::sqlite }
}
}
diff --git a/manifests/expire/mysql.pp b/manifests/expire/mysql.pp
new file mode 100644
index 0000000..5256d60
--- /dev/null
+++ b/manifests/expire/mysql.pp
@@ -0,0 +1,20 @@
+class dovecot::expire::mysql {
+
+ file { 'dovecot-dict-expire.conf':
+ source => [ "puppet:///modules/site_dovecot/expire/${fqdn}/mysql-dict-expire.conf",
+ "puppet:///modules/site_dovecot/expire/mysql-dict-expire.conf",
+ "puppet:///modules/dovecot/expire/${operatingsystem}/mysql-dict-expire.conf",
+ "puppet:///modules/dovecot/expire/mysql-dict-expire.conf" ],
+ path => $operatingsystem ? {
+ 'debian' => '/etc/dovecot/dovecot-dict-expire.conf',
+ default => '/etc/dovecot-dict-expire.conf'
+ },
+ require => $version ? {
+ 2 => Package['dovecot-mysql'],
+ default => Package['dovecot'],
+ },
+ notify => Service['dovecot'],
+ owner => root, group => 0, mode => 0600;
+ }
+
+}
diff --git a/manifests/expire/sqlite.pp b/manifests/expire/sqlite.pp
index a9fed4b..b1724e1 100644
--- a/manifests/expire/sqlite.pp
+++ b/manifests/expire/sqlite.pp
@@ -1,19 +1,22 @@
class dovecot::expire::sqlite {
- include ::sqlite
- file{'/var/lib/dovecot/expire.db':
- ensure => file,
- replace => false,
- require => Package['sqlite'],
- owner => root, group => 0, mode => 0600;
- }
- file{'/var/lib/dovecot/expire.sql':
- source => "puppet:///modules/dovecot/expire/expire.sqlite.sql",
- require => File['/var/lib/dovecot/expire.db'],
- notify => Exec['create_expire_db'],
- owner => root, group => 0, mode => 0600;
+
+ include dovecot::sql::sqlite
+
+ file {
+ '/var/lib/dovecot/expire.db':
+ ensure => file,
+ replace => false,
+ require => Package['sqlite'],
+ owner => root, group => 0, mode => 0600;
+
+ '/var/lib/dovecot/expire.sql':
+ source => "puppet:///modules/dovecot/expire/expire.sqlite.sql",
+ require => File['/var/lib/dovecot/expire.db'],
+ notify => Exec['create_expire_db'],
+ owner => root, group => 0, mode => 0600;
}
- exec{'create_expire_db':
+ exec { 'create_expire_db':
command => 'cat /var/lib/dovecot/expire.sql | sqlite3 /var/lib/dovecot/expire.db',
refreshonly => true,
}
diff --git a/manifests/init.pp b/manifests/init.pp
index a3b34ad..29d6da7 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -5,16 +5,17 @@ class dovecot(
$pgsql = false,
$mysql = false,
$nagios_checks = {
- 'imap-hostname' => $::fqdn,
- 'pop3-hostname' => $::fqdn,
+ 'imap-hostname' => $fqdn,
+ 'pop3-hostname' => $fqdn,
},
$munin_checks = true,
- $manage_shorewall = true
+ $manage_shorewall = true,
+ $version = 2
){
- case $::operatingsystem {
- centos: { include dovecot::centos }
- 'Debian','Ubuntu': { include dovecot::debian }
- default: { include dovecot::base }
+ case $operatingsystem {
+ centos: { include dovecot::centos }
+ debian: { include dovecot::debian }
+ default: { include dovecot::base }
}
if $dovecot::sqlite or $dovecot::pgsql or $dovecot::mysql {
diff --git a/manifests/logrotate.pp b/manifests/logrotate.pp
index a26e1c2..c86f0f0 100644
--- a/manifests/logrotate.pp
+++ b/manifests/logrotate.pp
@@ -1,11 +1,13 @@
class dovecot::logrotate {
+
include logrotate
+
augeas {
"logrotate_dovecot":
context => "/files/etc/logrotate.d/dovecot/rule",
- changes => [ 'set file /var/log/dovecot/*.log', 'set rotate 3', 'set schedule weekly',
+ changes => [ 'set file /var/log/dovecot/*.log', 'set rotate 3', 'set schedule daily',
'set compress compress', 'set sharedscripts sharedscripts',
- 'set create/mode 0660', 'set create/owner root', 'set create/group mail',
+ 'set create/mode 0660', 'set create/owner dovecot', 'set create/group dovecot',
'set postrotate "/bin/kill -USR1 `cat /var/run/dovecot/master.pid 2>/dev/null` 2> /dev/null || true"' ],
}
}
diff --git a/manifests/managesieve.pp b/manifests/managesieve.pp
index efe4435..625de4a 100644
--- a/manifests/managesieve.pp
+++ b/manifests/managesieve.pp
@@ -5,7 +5,13 @@ class dovecot::managesieve(
'sieve-hostname' => $::fqdn,
}
) {
- package{'dovecot-managesieve':
+
+ $managesieve_package = $operatingsystem ? {
+ debian => managesieved,
+ default => managesieve
+ }
+
+ package { $managesieve_package:
ensure => installed,
before => Service['dovecot'],
}
@@ -18,7 +24,7 @@ class dovecot::managesieve(
}
if $dovecot::managesieve::nagios_checks {
- nagios::service{"managesieve":
+ nagios::service { "managesieve":
check_command => "check_managesieve!${dovecot::managesieve::nagios_checks['sieve-hostname']}";
}
}
diff --git a/manifests/munin.pp b/manifests/munin.pp
index 56b6945..5996604 100644
--- a/manifests/munin.pp
+++ b/manifests/munin.pp
@@ -1,12 +1,7 @@
class dovecot::munin {
+
munin::plugin::deploy{'dovecot':
source => "dovecot/munin/dovecot",
- config => "env.logfile /var/log/dovecot/infos.log
-group mail"
- } -> file{'/var/lib/munin/plugin-state/plugin-dovecot.state':
- ensure => file,
- owner => munin,
- group => mail,
- mode => 0660;
+ config => "env.logfile /var/log/dovecot/dovecot.log\ngroup dovecot"
}
}
diff --git a/manifests/quota.pp b/manifests/quota.pp
index a4a3255..c44e0c1 100644
--- a/manifests/quota.pp
+++ b/manifests/quota.pp
@@ -1,4 +1,5 @@
class dovecot::quota {
+
file{'/usr/libexec/dovecot/quota-warning.sh':
source => [ "puppet:///modules/site_dovecot/quota/quota-warning.sh",
"puppet:///modules/dovecot/quota/quota-warning.sh" ],
diff --git a/manifests/sieve.pp b/manifests/sieve.pp
index c0aa54c..5666420 100644
--- a/manifests/sieve.pp
+++ b/manifests/sieve.pp
@@ -1,38 +1,77 @@
class dovecot::sieve {
+
include ::dovecot
+
package{'dovecot-sieve':
ensure => installed,
before => Service['dovecot'],
}
- file{'/var/lib/dovecot-sieve':
- ensure => directory,
- owner => root, group => 0, mode => 0644;
+ $sieve_location = $operatingsystem ? {
+ debian => '/var/lib/dovecot/sieve',
+ default => '/var/lib/dovecot-sieve'
}
- file{'/var/lib/dovecot-sieve/global':
+
+ file {
+ $sieve_location:
+ ensure => directory,
+ owner => root, group => mail, mode => 0775;
+
+ "${sieve_location}/global":
ensure => directory,
recurse => true,
purge => true,
force => true,
notify => Exec['compile_global_sieve'],
owner => root, group => root, mode => 0644;
- }
- file{'/var/lib/dovecot-sieve/default.sieve':
- source => [ "puppet:///modules/site_dovecot/sieve/${::fqdn}/default.sieve",
- "puppet:///modules/site_dovecot/sieve/default.sieve",
- "puppet:///modules/dovecot/sieve/${::operatingsystem}/default.sieve",
+
+ "${sieve_location}/default.sieve":
+ source => [ "puppet:///modules/site_dovecot/sieve/${fqdn}/default.sieve",
+ "puppet:///modules/site_dovecot/sieve/default.sieve",
+ "puppet:///modules/dovecot/sieve/${operatingsystem}/default.sieve",
"puppet:///modules/dovecot/sieve/default.sieve" ],
notify => Exec['compile_default_sieve'],
+ owner => root, group => root, mode => 0644;
+
+ # this is for sequential sieve scripts, configured in 90-sieve.conf as:
+ # sieve_before = /var/lib/dovecot/sieve/default.sieve
+ "${sieve_location}/before.sieve":
+ source => [ "puppet:///modules/site_dovecot/sieve/${fqdn}/before.sieve",
+ "puppet:///modules/site_dovecot/sieve/before.sieve",
+ "puppet:///modules/dovecot/sieve/${operatingsystem}/before.sieve",
+ "puppet:///modules/dovecot/sieve/before.sieve" ],
+ notify => Exec['compile_before_sieve'],
+ owner => root, group => root, mode => 0644;
+
+ # this is for sequential sieve scripts, configured in 90-sieve.conf as:
+ # sieve_after = /var/lib/dovecot/sieve/after.sieve
+ "${sieve_location}/after.sieve":
+ source => [ "puppet:///modules/site_dovecot/sieve/${fqdn}/after.sieve",
+ "puppet:///modules/site_dovecot/sieve/after.sieve",
+ "puppet:///modules/dovecot/sieve/${operatingsystem}/after.sieve",
+ "puppet:///modules/dovecot/sieve/after.sieve" ],
+ notify => Exec['compile_after_sieve'],
owner => root, group => root, mode => 0644;
}
- exec{'compile_default_sieve':
- command => 'sievec /var/lib/dovecot-sieve/default.sieve',
- creates => '/var/lib/dovecot-sieve/default.svbin',
- require => File['/var/lib/dovecot-sieve/default.sieve'],
- }
- exec{'compile_global_sieve':
- command => 'sievec /var/lib/dovecot-sieve/global/',
- refreshonly => true,
+ exec {
+ 'compile_default_sieve':
+ command => "sievec ${sieve_location}/default.sieve",
+ creates => "${sieve_location}/default.svbin",
+ require => File["${sieve_location}/default.sieve"];
+
+ 'compile_before_sieve':
+ command => "sievec ${sieve_location}/before.sieve",
+ creates => "${sieve_location}/before.svbin",
+ require => File["${sieve_location}/before.sieve"];
+
+ 'compile_after_sieve':
+ command => "sievec ${sieve_location}/after.sieve",
+ creates => "${sieve_location}/after.svbin",
+ require => File["${sieve_location}/after.sieve"];
+
+ 'compile_global_sieve':
+ command => "sievec ${sieve_location}/global/",
+ refreshonly => true;
}
}
diff --git a/manifests/sql.pp b/manifests/sql.pp
index 0db154b..b35ebdc 100644
--- a/manifests/sql.pp
+++ b/manifests/sql.pp
@@ -1,15 +1,27 @@
class dovecot::sql {
+
file{'/etc/dovecot-sql.conf':
- source => [ "puppet:///modules/site_dovecot/sql/${::fqdn}/dovecot-sql.conf",
+ source => [ "puppet:///modules/site_dovecot/sql/${fqdn}/dovecot-sql.conf",
"puppet:///modules/site_dovecot/sql/${dovecot::type}/dovecot-sql.conf",
"puppet:///modules/site_dovecot/sql/dovecot-sql.conf",
- "puppet:///modules/site/sql/${::operatingsystem}/dovecot-sql.conf",
+ "puppet:///modules/site/sql/${operatingsystem}/dovecot-sql.conf",
"puppet:///modules/site/sql/dovecot-sql.conf" ],
require => Package['dovecot'],
notify => Service['dovecot'],
owner => root, group => 0, mode => 0600;
}
+ file { '/etc/dovecot-dict-sql.conf':
+ source => [ "puppet:///modules/site_dovecot/sql/${fqdn}/dovecot-dict-sql.conf",
+ "puppet:///modules/site_dovecot/sql/${dovecot::type}/dovecot-dict-sql.conf",
+ "puppet:///modules/site_dovecot/sql/dovecot-dict-sql.conf",
+ "puppet:///modules/site/sql/${operatingsystem}/dovecot-dict-sql.conf",
+ "puppet:///modules/site/sql/dovecot-dict-sql.conf" ],
+ require => Package['dovecot'],
+ notify => Service['dovecot'],
+ owner => root, group => 0, mode => 0600;
+ }
+
if $dovecot::mysql {
include ::dovecot::sql::mysql
}
@@ -19,4 +31,9 @@ class dovecot::sql {
if $dovecot::sqlite {
include ::dovecot::sql::sqlite
}
+
+ if $operatingsystem == 'Debian' {
+ File['/etc/dovecot-sql.conf'] { path => '/etc/dovecot/dovecot-sql.conf' }
+ File['/etc/dovecot-dict-sql.conf'] { path => '/etc/dovecot/dovecot-dict-sql.conf' }
+ }
}
diff --git a/manifests/sql/mysql.pp b/manifests/sql/mysql.pp
index 378ed41..56cbb13 100644
--- a/manifests/sql/mysql.pp
+++ b/manifests/sql/mysql.pp
@@ -1,6 +1,9 @@
class dovecot::sql::mysql {
- package{'dovecot-mysql':
- ensure => installed,
- before => File['/etc/dovecot-sql.conf'],
+
+ if $version == 2 {
+ package { 'dovecot-mysql':
+ ensure => installed,
+ before => [ File['/etc/dovecot-sql.conf'], File['/etc/dovecot-dict-sql.conf'] ];
+ }
}
}
diff --git a/manifests/sql/pgsql.pp b/manifests/sql/pgsql.pp
index 530e878..39f1b64 100644
--- a/manifests/sql/pgsql.pp
+++ b/manifests/sql/pgsql.pp
@@ -1,6 +1,9 @@
class dovecot::sql::pgsql {
- package{'dovecot-pgsql':
- ensure => installed,
- before => File['/etc/dovecot-sql.conf'],
+
+ if $version == 2 {
+ package { 'dovecot-pgsql':
+ ensure => installed,
+ before => File['/etc/dovecot-sql.conf'],
+ }
}
}
diff --git a/manifests/sql/sqlite.pp b/manifests/sql/sqlite.pp
index bc07fb7..c2a848e 100644
--- a/manifests/sql/sqlite.pp
+++ b/manifests/sql/sqlite.pp
@@ -1,6 +1,9 @@
class dovecot::sql::sqlite {
- package{'dovecot-sqlite':
- ensure => installed,
- before => File['/etc/dovecot-sql.conf'],
+
+ if $version == 2 {
+ package { 'dovecot-sqlite':
+ ensure => installed,
+ before => File['/etc/dovecot-sql.conf'],
+ }
}
}