summaryrefslogtreecommitdiff
path: root/manifests/postfixadmin.pp
blob: 3ab50e4b687459e5b9d43de60b0eade600907737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
class mail::postfixadmin(
  $database_user = hiera('postfixadmin_database_user', 'postfix'),
  $database_host = hiera('postfixadmin_database_host', 'localhost'),
  $database_name = hiera('postfixadmin_database_name', 'postfix'),
  $database_password = hiera('postfixadmin_database_password', ''),
) {
  # Class configuration
  case $database_password {
    '': { fail("You need to define database_password host config") }
  }

  #
  # Database configuration
  #
  database::instance { "${database_name}":
    password => "${database_password}",
  }

  #
  # Postfix configuration
  #
  postfix::config {
    "virtual_transport": value => 'dovecot';
    "dovecot_destination_recipient_limit": value => '1', nonstandard => true;
  }

  postfix::config { "virtual_mailbox_domains":
    value   => 'proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf',
    require => File['/etc/postfix/sql/mysql_virtual_domains_maps.cf'],
  }

  postfix::config { "virtual_alias_maps":
    value   => 'hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual_regexp, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf',
    require => File['/etc/postfix/sql/mysql_virtual_alias_maps.cf',
                    '/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf',
                    '/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf' ],
  }

  postfix::config { "virtual_mailbox_maps": 
    value   => 'proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf',
    require => File['/etc/postfix/sql/mysql_virtual_mailbox_maps.cf',
                    '/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf' ],
  }

  #
  # Map files
  #
  file { "/etc/postfix/sql":
    ensure => directory,
    owner  => postfix,
    group  => root,
    mode   => 0755,
  }

  file { "/etc/postfix/sql/mysql_virtual_domains_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_domains_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  file { "/etc/postfix/sql/mysql_virtual_alias_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_alias_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  file { "/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_alias_domain_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  file { "/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  file { "/etc/postfix/sql/mysql_virtual_mailbox_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_mailbox_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  file { "/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf":
    ensure  => present,
    owner   => postfix,
    mode    => 0600,
    content => template('mail/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf.erb'),
    require => File['/etc/postfix/sql'],
  }

  #
  # Additional for quota support
  #
  #postfix::config { "virtual_mailbox_limit_maps": 
  #  value   => 'mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf',
  #  require => File['/etc/postfix/mysql_virtual_mailbox_limit_maps.cf'],
  #}
  #
  #postfix::config { "virtual_create_maildirsize":     value => 'yes' }
  #postfix::config { "virtual_mailbox_extended ":      value => 'yes' }
  #postfix::config { "virtual_mailbox_limit_override": value => 'yes' }
  #postfix::config { "virtual_maildir_limit_message":  value => 'The user's maildir has overdrawn his quota, try again later.' }
  #postfix::config { "virtual_overquota_bounce":       value => 'yes' }
  #
  #file { "/etc/postfix/mysql_virtual_mailbox_limit_maps.cf":
  #  ensure  => present,
  #  owner   => postfix,
  #  mode    => 0600,
  #  content => template('mail/postfix/sql/mysql_virtual_mailbox_limit_maps.cf.erb'),
  #  require => File['/etc/postfix/sql'],
  #}
}