spip.pp 5.35 KB
Newer Older
mh's avatar
mh committed
1
2
3
4
5
6
# domainalias:
#   - www: add as well a www.${name} entry
#   - absent: do nothing
#   - default: add the string
# run_mode:
#   - normal: nothing special (*default*)
7
8
9
#   - fcgid: apache is running with fcgid and suexec
# run_uid: the uid the vhost should run as with the suexec module
# run_gid: the gid the vhost should run as with the suexec module
mh's avatar
mh committed
10
11
12
13
14
15
#
# 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
16
define webhosting::php::spip(
17
18
19
20
21
22
23
24
25
26
27
28
  $ensure                = present,
  $configuration         = {},
  $uid                   = 'absent',
  $uid_name              = 'absent',
  $gid                   = 'uid',
  $gid_name              = 'absent',
  $password              = 'absent',
  $password_crypted      = true,
  $domainalias           = 'www',
  $server_admin          = 'absent',
  $logmode               = 'default',
  $owner                 = root,
29
  $group                 = 'absent',
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
  $run_mode              = 'normal',
  $run_uid               = 'absent',
  $run_uid_name          = 'absent',
  $run_gid               = 'absent',
  $run_gid_name          = 'absent',
  $watch_adjust_webfiles = 'absent',
  $user_scripts          = 'absent',
  $user_scripts_options  = {},
  $wwwmail               = false,
  $allow_override        = 'FileInfo',
  $do_includes           = false,
  $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,
  $git_repo              = 'absent',
mh's avatar
mh committed
59
){
mh's avatar
linting    
mh committed
60
61
62
63
64
65
66
67
68
69
  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
  }
70
71
72
73
74
  if ($group == 'absent') {
    $real_group = $real_gid_name
  } else {
    $real_group = 'apache'
  }
75
76
77
78

  $path = "/var/www/vhosts/${name}"
  $documentroot = "${path}/www"

mh's avatar
linting    
mh committed
79
80
  webhosting::common{$name:
    ensure                => $ensure,
o@immerda.ch's avatar
o@immerda.ch committed
81
    configuration         => $configuration,
mh's avatar
linting    
mh committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    uid                   => $uid,
    uid_name              => $real_uid_name,
    gid                   => $gid,
    gid_name              => $real_gid_name,
    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,
    user_scripts          => $user_scripts,
    user_scripts_options  => $user_scripts_options,
    watch_adjust_webfiles => $watch_adjust_webfiles,
    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,
103
    git_repo              => $git_repo,
mh's avatar
linting    
mh committed
104
  }
mh's avatar
mh committed
105

mh's avatar
linting    
mh committed
106
  apache::vhost::php::spip{$name:
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    ensure             => $ensure,
    configuration      => $configuration,
    domainalias        => $domainalias,
    server_admin       => $server_admin,
    logmode            => $logmode,
    group              => $group,
    allow_override     => $allow_override,
    do_includes        => $do_includes,
    options            => $options,
    additional_options => $additional_options,
    default_charset    => $default_charset,
    run_mode           => $run_mode,
    ssl_mode           => $ssl_mode,
    php_settings       => $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,
mh's avatar
linting    
mh committed
127
128
  }
  case $run_mode {
129
    'fcgid': {
mh's avatar
linting    
mh committed
130
131
132
133
134
135
136
      if ($run_uid_name == 'absent'){
        $real_run_uid_name = "${name}_run"
      } else {
        $real_run_uid_name = $run_uid_name
      }
      if ($run_gid_name == 'absent'){
        $real_run_gid_name = $gid_name ? {
137
138
          'absent' => $name,
          default  => $gid_name
mh's avatar
mh committed
139
        }
mh's avatar
linting    
mh committed
140
141
142
143
144
145
      } else {
        $real_run_gid_name = $run_gid_name
      }
      Apache::Vhost::Php::Spip[$name]{
        documentroot_owner => $real_uid_name,
        documentroot_group => $real_gid_name,
146
147
148
149
        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] ],
mh's avatar
linting    
mh committed
150
      }
mh's avatar
mh committed
151
    }
mh's avatar
linting    
mh committed
152
    default: {
mh's avatar
mh committed
153
      Apache::Vhost::Php::Spip[$name]{
mh's avatar
linting    
mh committed
154
        require => User::Sftp_only[$real_uid_name],
mh's avatar
mh committed
155
156
      }
    }
mh's avatar
linting    
mh committed
157
158
159
160
161
162
  }
  if $template_partial != 'absent' {
    Apache::Vhost::Php::Spip[$name]{
      template_partial => $template_partial
    }
  }
mh's avatar
mh committed
163
}