summaryrefslogtreecommitdiff
path: root/manifests/sympa.pp
blob: a9c45d3b92d2ce0cf890b9a8204e636e091ff63d (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
125
126
127
128
129
130
131
132
133
134
class mail::sympa inherits mail::regexps {
  # Sympa subsystems
  include mail::web::sympa
  include mail::packages::sympa

  # Class configuration
  case $sympa_database_password {
    '': { fail("You need to define \$sympa_database_password host config") }
  }

  case $sympa_database_name {
    '': { $sympa_database_name= "sympa" }
  }

  case $sympa_database_host {
    '': { $sympa_database_host = "localhost" }
  }

  case $sympa_listmasters {
    '': { $sympa_listmasters = "listmaster@${fqdn}" }
  }

  case $sympa_lang {
    '': { $sympa_lang = "en_US" }
  }

  #
  # Database configuration
  #
  database::instance { "$sympa_database_name":
    password => "$sympa_database_password",
  }

  group { 'sympa':
    ensure => present,
  }

  user { 'sympa':
    ensure  => present,
    gid     => 'sympa',
    require => Group['sympa'],
  }

  service { "sympa":
    ensure    => running,
    enable    => true,
    hasstatus => false,
    pattern   => '/usr/lib/sympa/bin/sympa.pl',
  }

  file { "/etc/sympa":
    ensure => directory,
    owner  => postfix,
    group  => root,
    mode   => 0755,
  }

  file { "/etc/sympa/sympa.conf":
    ensure  => present,
    owner   => sympa,
    group   => sympa,
    mode    => 0640,
    content => template('mail/sympa/sympa.conf.erb'),
    require => [ File['/etc/sympa'], User['sympa'] ],
    notify  => Service['apache', 'sympa'],
  }

  File["/etc/postfix/transport_regexp"] {
    content => template('mail/postfix/sympa/transport_regexp.erb'),
  }

  File["/etc/postfix/virtual_regexp"] {
    content => template('mail/postfix/sympa/virtual_regexp.erb'),
  }

  postfix::config {
    "sympa_destination_recipient_limit":       value => '1';
    "sympabounce_destination_recipient_limit": value => '1';
  }

  mailalias { "sympa":
    recipient => "|/usr/lib/sympa/bin/queue sympa",
    notify    => Exec["newaliases"],
  }

  mailalias { "sympa-request":
    recipient => "postmaster",
    notify    => Exec["newaliases"],
  }

  mailalias { "sympa-owner":
    recipient => "postmaster",
    notify    => Exec["newaliases"],
  }

  mailalias { "listmaster":
    recipient => "postmaster",
    notify    => Exec["newaliases"],
  }

  mailalias { "postmaster":
    recipient => "root",
    notify    => Exec["newaliases"],
  }
}

class mail::sympa::disabled inherits mail::sympa {
  include mail::web::sympa::disabled

  Service["sympa"] {
    ensure    => stopped,
    enable    => false,
  }

  File["/etc/postfix/transport_regexp"] {
    content => undef,
  }

  File["/etc/postfix/virtual_regexp"] {
    content => undef,
  }

  Mailalias["sympa"] {
    ensure => absent,
  }

  Mailalias["sympa-request"] {
    ensure => absent,
  }

  Mailalias["sympa-owner"] {
    ensure => absent,
  }
}