mediawiki.pp 7.36 KB
Newer Older
mh's avatar
mh committed
1
2
3
4
5
6
7
8
9
10
11
12
13
# domainalias:
#   - www: add as well a www.${name} entry
#   - absent: do nothing
#   - default: add the string
# user_provider:
#   - local: user will be crated locally (*default*)
#   - everything else will currently do noting
# run_mode:
#   - normal: nothing special (*default*)
#   - itk: apache is running with the itk module
#          and run_uid and run_gid are used as vhost users
# run_uid: the uid the vhost should run as with the itk module
# run_gid: the gid the vhost should run as with the itk module
mh's avatar
mh committed
14
15
16
17
18
19
#
# logmode:
#   - default: Do normal logging to CustomLog and ErrorLog
#   - nologs: Send every logging to /dev/null
#   - anonym: Don't log ips for CustomLog, send ErrorLog to /dev/null
#   - semianonym: Don't log ips for CustomLog, log normal ErrorLog
mh's avatar
mh committed
20
define webhosting::php::mediawiki(
mh's avatar
linting    
mh committed
21
  $ensure               = present,
o@immerda.ch's avatar
o@immerda.ch committed
22
  $configuration        = {},
mh's avatar
linting    
mh committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  $uid                  = 'absent',
  $uid_name             = 'absent',
  $gid                  = 'uid',
  $gid_name             = 'absent',
  $user_provider        = 'local',
  $password             = 'absent',
  $password_crypted     = true,
  $domainalias          = 'www',
  $server_admin         = 'absent',
  $logmode              = 'default',
  $owner                = root,
  $group                = 'sftponly',
  $run_mode             = 'normal',
  $run_uid              = 'absent',
  $run_uid_name         = 'absent',
  $run_gid              = 'absent',
  $run_gid_name         = 'absent',
  $wwwmail              = false,
mh's avatar
mh committed
41
  $allow_override       = 'FileInfo Limit Options=FollowSymLinks',
mh's avatar
linting    
mh committed
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
  $options              = 'absent',
  $additional_options   = 'absent',
  $default_charset      = 'absent',
  $ssl_mode             = false,
  $php_settings         = {},
  $php_options          = {},
  $vhost_mode           = 'template',
  $template_partial     = 'absent',
  $vhost_source         = 'absent',
  $vhost_destination    = 'absent',
  $htpasswd_file        = 'absent',
  $nagios_check         = 'ensure',
  $nagios_check_domain  = 'absent',
  $nagios_check_url     = '/',
  $nagios_check_code    = '200',
  $nagios_use           = 'generic-service',
  $mod_security         = true,
  $image                = 'absent',
  $config               = 'unmanaged',
  $db_server            = 'unmanaged',
  $db_name              = 'unmanaged',
  $db_user              = 'db_name',
  $db_pwd               = 'unmanaged',
  $contact              = 'unmanaged',
  $sitename             = 'unmanaged',
  $secret_key           = 'unmanaged',
  $spam_protection      = false,
  $wiki_options         = {},
  $autoinstall          = true,
  $squid_servers        = 'absent',
  $file_extensions      = 'absent',
  $extensions           = 'absent',
  $language             = 'de',
  $hashed_upload_dir    = true
mh's avatar
mh committed
76
){
mh's avatar
linting    
mh committed
77
78
79
80
81
82
83
84
85
86
87
  if ($uid_name == 'absent'){
    $real_uid_name = $name
  } else {
    $real_uid_name = $uid_name
  }
  if ($gid_name == 'absent'){
    $real_gid_name = $real_uid_name
  } else {
    $real_gid_name = $gid_name
  }
  webhosting::common{$name:
mh's avatar
linting    
mh committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    ensure              => $ensure,
    configuration       => $configuration,
    uid                 => $uid,
    uid_name            => $real_uid_name,
    gid                 => $gid,
    gid_name            => $real_gid_name,
    user_provider       => $user_provider,
    password            => $password,
    password_crypted    => $password_crypted,
    htpasswd_file       => $htpasswd_file,
    ssl_mode            => $ssl_mode,
    run_mode            => $run_mode,
    run_uid             => $run_uid,
    run_uid_name        => $run_uid_name,
    run_gid             => $run_gid,
    wwwmail             => $wwwmail,
    nagios_check        => $nagios_check,
    nagios_check_domain => $nagios_check_domain,
    nagios_check_url    => $nagios_check_url,
    nagios_check_code   => $nagios_check_code,
    nagios_use          => $nagios_use,
mh's avatar
linting    
mh committed
109
  }
mh's avatar
mh committed
110

mh's avatar
linting    
mh committed
111
  if $wwwmail and ($contact != 'unmanaged'){
mh's avatar
mh committed
112
113
114
115
116
117
118
    $sendmail_path = "/usr/sbin/sendmail -t -f${contact} -i"
  } else {
    $sendmail_path = undef
  }
  $mediawiki_php_settings = {
    open_basedir  => "/var/www/mediawiki:/var/www/vhosts/${name}/www:/var/www/upload_tmp_dir/${name}:/var/www/session.save_path/${name}",
    sendmail_path => $sendmail_path,
mh's avatar
linting    
mh committed
119
120
  }
  $real_php_settings = merge($mediawiki_php_settings,$php_settings)
121

mh's avatar
linting    
mh committed
122
123
  apache::vhost::php::mediawiki{$name:
    ensure             => $ensure,
o@immerda.ch's avatar
o@immerda.ch committed
124
    configuration      => $configuration,
mh's avatar
linting    
mh committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    domainalias        => $domainalias,
    server_admin       => $server_admin,
    logmode            => $logmode,
    group              => $group,
    manage_docroot     => false,
    allow_override     => $allow_override,
    options            => $options,
    additional_options => $additional_options,
    default_charset    => $default_charset,
    run_mode           => $run_mode,
    ssl_mode           => $ssl_mode,
    php_settings       => $real_php_settings,
    php_options        => $php_options,
    vhost_mode         => $vhost_mode,
    vhost_source       => $vhost_source,
    vhost_destination  => $vhost_destination,
    htpasswd_file      => $htpasswd_file,
    mod_security       => $mod_security,
  }
  mediawiki::instance{$name:
mh's avatar
mh committed
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    ensure                  => $ensure,
    image                   => $image,
    config                  => $config,
    db_server               => $db_server,
    db_name                 => $db_name,
    db_user                 => $db_user,
    db_pwd                  => $db_pwd,
    contact                 => $contact,
    sitename                => $sitename,
    ssl_mode                => $ssl_mode,
    secret_key              => $secret_key,
    file_extensions         => $file_extensions,
    extensions              => $extensions,
    spam_protection         => $spam_protection,
    wiki_options            => $wiki_options,
    autoinstall             => $autoinstall,
    squid_servers           => $squid_servers,
    language                => $language,
    hashed_upload_dir       => $hashed_upload_dir,
mh's avatar
linting    
mh committed
164
    documentroot_write_mode => '0660',
mh's avatar
linting    
mh committed
165
  }
mh's avatar
mh committed
166

mh's avatar
linting    
mh committed
167
168
169
170
171
172
  case $run_mode {
    'fcgid','itk','proxy-itk','static-itk': {
      if ($run_uid_name == 'absent'){
        $real_run_uid_name = "${name}_run"
      } else {
        $real_run_uid_name = $run_uid_name
mh's avatar
mh committed
173
      }
mh's avatar
linting    
mh committed
174
175
176
177
      if ($run_gid_name == 'absent'){
        $real_run_gid_name = $gid_name ? {
          'absent' => $name,
          default  => $gid_name
mh's avatar
mh committed
178
        }
mh's avatar
linting    
mh committed
179
180
181
182
183
184
185
186
187
188
189
190
191
192
      } else {
        $real_run_gid_name = $run_gid_name
      }
      Apache::Vhost::Php::Mediawiki[$name]{
        documentroot_owner => $real_uid_name,
        documentroot_group => $real_gid_name,
        run_uid            => $real_run_uid_name,
        run_gid            => $real_run_gid_name,
        require            => [ User::Sftp_only[$real_uid_name],
                                User::Managed[$real_run_uid_name] ],
      }
      Mediawiki::Instance[$name]{
        documentroot_owner => $real_uid_name,
        documentroot_group => $real_gid_name,
mh's avatar
linting    
mh committed
193
        documentroot_mode  => '0640',
mh's avatar
linting    
mh committed
194
195
        require            => [ User::Sftp_only[$real_uid_name],
                                User::Managed[$real_run_uid_name] ],
mh's avatar
mh committed
196
197
      }
    }
mh's avatar
linting    
mh committed
198
    default: {
mh's avatar
mh committed
199
      Apache::Vhost::Php::Mediawiki[$name]{
mh's avatar
linting    
mh committed
200
201
202
203
        require => User::Sftp_only[$real_uid_name],
      }
      Mediawiki::Instance[$name]{
        require => User::Sftp_only[$real_uid_name],
mh's avatar
mh committed
204
205
      }
    }
mh's avatar
linting    
mh committed
206
207
208
209
210
211
  }
  if $template_partial != 'absent' {
    Apache::Vhost::Php::Mediawiki[$name]{
      template_partial => $template_partial
    }
  }
mh's avatar
mh committed
212
213
}