summaryrefslogtreecommitdiff
path: root/manifests/web.pp
blob: 16f4b25a8734eea658d1ac2ae29b8b6facfc2f02 (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
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
173
174
175
176
177
178
179
class mail::web::virtual(
  $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', ''),
  $postfixadmin_setup_hash = hiera('postfixadmin_setup_hash', ''),
  $roundcube_des_key = hiera('roundcube_des_key', ''),
  $roundcube_logo = hiera('roundcube_logo', 'null'),
  $roundcube_login_info = hiera('roundcube_login_info', false)
) {

  # Class configuration
  if $::lsbdistcodename != 'lenny' {
    case $roundcube_des_key {
      '': { fail("You need to define roundcube_des_key host config") }
    }
  }

  case $database_password {
    '': { fail("You need to define database_password host config") }
  }

  case $postfixadmin_setup_hash {
    '': {
      warning("You need to define postfixadmin_setup_hash host config")
      $setup_hash = 'changeme'
    }
  }

  include php::imap
  include websites::setup

  apache::site { "postfixadmin":
    docroot => "${apache::sites_folder}/postfixadmin/site",
    use     => [ "Site postfixadmin" ],
    mpm     => false,
  }

  apache::site { "mail":
    docroot => $::lsbdistcodename ? {
      'lenny' => "/usr/share/squirrelmail",
      default => "/var/lib/roundcube",
    },
    source  => true,
    mpm     => false,
  }

  file { "${apache::sites_folder}/postfixadmin/site/config.inc.php":
    ensure  => present,
    owner   => www-data,
    group   => root,
    mode    => 0640,
    content => template('mail/postfixadmin/config.inc.php.erb'),
    require => File["${apache::sites_folder}/postfixadmin/site"],
  }

  file { "/etc/roundcube/main.inc.php":
    ensure => $::lsbdistcodename ? {
      'lenny' => absent,
      default => present,
    },
    owner   => root,
    group   => www-data,
    mode    => 0640,
    content => template('mail/roundcube/main.inc.php.erb'),
    require => Package['roundcube'],
  }

  file { "/var/lib/roundcube/plugins/login_info":
    ensure => $::lsbdistcodename ? {
      'lenny' => absent,
      default => directory,
    },
    recurse => true,
    owner   => root,
    group   => root,
    mode    => 0644,
    source  => "puppet:///modules/mail/roundcube/plugins/login_info",
    require => Package['roundcube'],
  }
}

class mail::web::sympa inherits websites::setup {
  $sympa_subdomain = hiera('sympa_subdomain', 'lists')

  apache::site { "$sympa_subdomain":
    docroot => "${apache::www_folder}/${sympa_subdomain}",
    source  => true,
    owner   => sympa,
    group   => sympa,
    mpm     => false,
  }

  package { [ 'apache2-suexec', 'libapache2-mod-fcgid' ]:
    ensure => present,
  }

  apache::module { "fcgid":
    ensure  => present,
    require => Package["libapache2-mod-fcgid"],
  }

  apache::module { "suexec":
    ensure  => present,
    require => Package["apache2-suexec"],
  }

  file { "${apache::www_folder}/${sympa_subdomain}/wwsympa.fcgi":
    ensure  => present,
    owner   => sympa,
    group   => sympa,
    mode    => 0550,
    content => "#!/bin/sh\n/usr/lib/cgi-bin/sympa/wwsympa.fcgi\n",
    require => File["${apache::www_folder}/${sympa_subdomain}"],
  }
}

class mail::web::sympa::disabled inherits mail::web::sympa {
  Apache::Site["$sympa_subdomain"] {
    ensure => absent,
  }

  File["${apache::www_folder}/${sympa_subdomain}/wwsympa.fcgi"] {
    require => undef,
  }
}

class mail::web::mlmmj inherits websites::setup {
  $mlmmj_subdomain = hiera('mlmmj_subdomain')

  apache::site { "$mlmmj_subdomain":
    docroot     => "/usr/share/mlmmj-php-web-admin",
    owner       => 'mlmmj',
    group       => 'mlmmj',
    mpm_user    => 'mlmmj',
    mpm_group   => 'mlmmj',
    manage_user => false,
    require     => Package['mlmmj-php-web-admin'],
  }

  package { [ 'mlmmj-php-web', 'mlmmj-php-web-admin' ]:
    ensure => present,
  }

  file { '/etc/mlmmj-php-web-admin':
    ensure => directory,
    owner  => mlmmj,
    group  => mlmmj,
    mode   => 0640,
  }

  file { '/etc/mlmmj-php-web-admin/htpasswd':
    ensure => present,
    owner  => mlmmj,
    group  => mlmmj,
    mode   => 0640,
    source => [ "puppet:///modules/site_mail/mlmmj/htpasswd",
                "puppet:///modules/mail/mlmmj/htpasswd" ],
  }
}

class mail::web::mlmmj::disabled inherits mail::web::mlmmj {
  Apache::Site["$mlmmj_subdomain"] {
    ensure => absent,
  }

  Package[ 'mlmmj-php-web', 'mlmmj-php-web-admin' ] {
    ensure => absent,
  }

  File['/etc/mlmmj-php-web-admin'] {
    ensure => absent,
    force  => true,
  }

  File['/etc/mlmmj-php-web-admin/htpasswd'] {
    ensure => absent,
  }
}