Puppet Class: postfix::vmail

Inherits:
postfix::params
Defined in:
manifests/vmail.pp

Overview

TODO RBL reject_rbl_client rbl_domain=d.d.d.d smtpd_recipient_restrictions = … reject_unauth_destination reject_rbl_client zen.smaphaus.org

LOCAL caching DNS server required

filtering www.postfix.org/FILTER_README.html

amavis-new forums.sentora.org/showthread.php?tid=1132

Parameters:

  • mailbox_base (Any) (defaults to: '/var/vmail')
  • setup_dovecot (Any) (defaults to: true)
  • smtpd_recipient_restrictions (Any) (defaults to: [ 'permit_inet_interfaces', 'permit_mynetworks', 'reject_authenticated_sender_login_mismatch', 'permit_sasl_authenticated', 'reject_unauth_destination', 'reject' ])
  • smtpd_relay_restrictions (Any) (defaults to: [ 'permit_inet_interfaces', 'permit_mynetworks', 'reject_authenticated_sender_login_mismatch', 'permit_sasl_authenticated', 'reject_unauth_destination', 'reject' ])


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'manifests/vmail.pp', line 14

class postfix::vmail(
                      $mailbox_base                 = '/var/vmail',
                      $setup_dovecot                = true,
                      #TODO: rewrite
                      $smtpd_recipient_restrictions = [ 'permit_inet_interfaces',
                                                        'permit_mynetworks',
                                                        'reject_authenticated_sender_login_mismatch',
                                                        'permit_sasl_authenticated',
                                                        'reject_unauth_destination',
                                                        'reject'
                                                        ],
                      $smtpd_relay_restrictions     = [ 'permit_inet_interfaces',
                                                        'permit_mynetworks',
                                                        'reject_authenticated_sender_login_mismatch',
                                                        'permit_sasl_authenticated',
                                                        'reject_unauth_destination',
                                                        'reject'
                                                        ],
                    ) inherits postfix::params {
  Exec {
    path => '/bin:/sbin:/usr/bin:/usr/sbin',
  }

  if($setup_dovecot)
  {
    class { 'dovecot':
      default_login_user => $postfix::postfix_username,
      first_valid_uid    => $postfix::postfix_username_uid,
      first_valid_gid    => $postfix::postfix_username_gid,
      mail_location      => "maildir:${mailbox_base}/%d/%n",
    }

    class { 'dovecot::userdb':
      uid  => $postfix::postfix_username_uid,
      gid  => $postfix::postfix_username_gid,
      home => "${mailbox_base}/%d/%n",
    }

    class { 'dovecot::passdb': }

    class { 'dovecot::auth': }

    class { 'dovecot::auth::unixlistener':
      user  => $postfix::postfix_username,
      group => $postfix::postfix_username,
    }

    class { 'dovecot::imaplogin':
      user => $postfix::postfix_username,
    }

    class { 'postfix::vmail::sasl':
      smtpd_sasl_type => 'dovecot',
    }
  }

  exec { 'eyp-postfix mailbox base':
    command => "mkdir -p ${mailbox_base}",
    creates => $mailbox_base,
  }

  file { $mailbox_base:
    ensure   => 'directory',
    owner    => $postfix::postfix_username,
    group    => $postfix::postfix_username,
    mode     => '0770',
    selrange => 's0',
    selrole  => 'object_r',
    seltype  => 'mail_spool_t',
    seluser  => 'system_u',
    require  => Exec['eyp-postfix mailbox base'],
    before   => Class['postfix::service'],
  }

  #
  # vmail base config
  #

  concat::fragment{ '/etc/postfix/main.cf vmail base':
    target  => '/etc/postfix/main.cf',
    order   => '50',
    content => template("${module_name}/vmail/vmail.erb"),
  }

  #
  # virtual mailboxes
  #

  concat::fragment{ '/etc/postfix/main.cf virtual_mailbox_maps':
    target  => '/etc/postfix/main.cf',
    order   => '52',
    content => "\n# virtual mailboxes\nvirtual_mailbox_maps=hash:/etc/postfix/vmail_mailbox\n",
  }

  concat { "${postfix::params::baseconf}/vmail_mailbox":
    ensure  => 'present',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    require => Package[$postfix::params::package_name],
    notify  => Exec['reload postfix mailbox'],
  }

  concat::fragment{ '/etc/postfix/vmail_mailbox header':
    target  => "${postfix::params::baseconf}/vmail_mailbox",
    order   => '00',
    content => template("${module_name}/vmail/mailbox/header.erb"),
  }

  exec { 'reload postfix mailbox':
    command     => "postmap ${postfix::params::baseconf}/vmail_mailbox",
    refreshonly => true,
    notify      => Class['postfix::service'],
    require     => [ Package[$postfix::params::package_name], Concat["${postfix::params::baseconf}/vmail_mailbox"] ],
  }

  #
  # virtual domains
  #
  #virtual_mailbox_domains=hash:/etc/postfix/vmail_domains

  concat::fragment{ '/etc/postfix/main.cf virtual_mailbox_domains':
    target  => '/etc/postfix/main.cf',
    order   => '53',
    content => "\n# virtual domains\nvirtual_mailbox_domains=hash:/etc/postfix/vmail_domains\n",
  }

  concat { "${postfix::params::baseconf}/vmail_domains":
    ensure  => 'present',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    require => Package[$postfix::params::package_name],
    notify  => Exec['reload postfix domains'],
  }

  concat::fragment{ '/etc/postfix/vmail_domains header':
    target  => "${postfix::params::baseconf}/vmail_domains",
    order   => '00',
    content => template("${module_name}/vmail/domains/header.erb"),
  }

  exec { 'reload postfix domains':
    command     => "postmap ${postfix::params::baseconf}/vmail_domains",
    refreshonly => true,
    notify      => Class['postfix::service'],
    require     => [ Package[$postfix::params::package_name], Concat["${postfix::params::baseconf}/vmail_domains"] ],
  }

  #
  # smtpd restrictions
  #

  concat::fragment{ '/etc/postfix/main.cf smtpd_restrictions':
    target  => '/etc/postfix/main.cf',
    order   => '55',
    content => template("${module_name}/smtpd_restrictions.erb"),
  }
}