aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystems/websites.pp
blob: 206b443283b4062f4c6532503ec46e475d62224d (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
class websites::setup {
  # Configure Apache Web Server
  $apache_www_folder   = "/var/www/data"
  $apache_error_folder = "/var/www/error"
  $apache_sites_folder = "/var/sites"
  $apache_error_dest   = "http://${domain}/missing.html"
  $drupal_folder       = "${apache_www_folder}/drupal"
  $viewvc_root_parents = "/var/svn : svn"

  $default_vhost = $apache_server_name ? {
    ''      => $hostname,
    default => $apache_server_name,
  }

  # Include apache
  include apache

  # The needed apache modules
  apache::module { "alias":
    ensure  => present,
  }

  # Images folder
  file { "${apache_www_folder}/images":
    ensure  => directory,
    recurse => true,
    purge   => true,
    force   => true,
    owner   => "root",
    group   => "root",
    # This mode will also apply to files from the source directory
    mode    => 0644,
    # Puppet will automatically set +x for directories
    source  => [ "puppet:///modules/site-apache/htdocs/$domain/images",
                 "puppet:///modules/nodo/htdocs/images", ]
  }

  # Web index
  file { "${apache_www_folder}/index.html":
    ensure  => present,
    owner   => "root",
    group   => "root",
    mode    => 0644,
    source  => [ "puppet:///modules/site-apache/htdocs/$domain/index.html",
                 "puppet:///modules/nodo/htdocs/index.html", ]
  }

  # Missing page
  file { "${apache_www_folder}/missing.html":
    ensure  => present,
    owner   => "root",
    group   => "root",
    mode    => 0644,
    source  => [ "puppet:///modules/site-apache/htdocs/$domain/missing.html",
                 "puppet:///modules/nodo/htdocs/missing.html", ]
  }

  # Make sure that a top level index exists
  file { "/var/www/index.html":
    ensure => present,
  }

  # Default vhost: can just be applied on the defining host
  apache::site { "$default_vhost":
    server_alias => "$domain",
    docroot      => "${apache_www_folder}",
    mpm          => false,
    tag          => 'all',
  }

  # We have to use 'zzz-error' so it will be the last matched vhost
  apache::site { "error":
    template       => 'apache/error.erb',
    docroot        => "${apache_error_folder}",
    filename       => 'zzz-error',
    mpm            => false,
    tag            => 'all',
  }

  # Index page for error
  file { "${apache_error_folder}/index.html":
    ensure  => "${apache_www_folder}/index.html",
    owner   => "root",
    group   => "root",
    force   => true,
    require => File["$apache_error_folder"],
  }

  # Images folder for error
  file { "${apache_error_folder}/images":
    ensure  => "${apache_www_folder}/images",
    owner   => "root",
    group   => "root",
    force   => true,
    require => File["$apache_error_folder", "${apache_www_folder}/images"],
  }

  # TODO: this is temporary: remove when all nodes have applied it
  # We have to use 'zzz-erro' so it will be the last matched vhost
  apache::site { "erro":
    ensure         => absent,
    docroot        => '/var/www/erro',
    filename       => 'zzz-erro',
    tag            => 'all',
  }

  # TODO: this is temporary: remove when all nodes have applied it
  file { "/var/www/erro":
    ensure  => absent,
    recurse => true,
    force   => true,
  }

  # TODO: this is temporary: remove when all nodes have applied it
  # Index page for erro
  file { "/var/www/erro/index.html":
    ensure  => absent,
    owner   => "root",
    group   => "root",
    force   => true,
  }

  # TODO: this is temporary: remove when all nodes have applied it
  file { "/var/www/erro/missing.html":
    ensure  => absent,
  }
}

class websites::hosting inherits websites::setup {
  # Include the needed classes for website hosting
  include php
  include drupal
  include gitweb
  include trac
  include websvn
  include viewvc
  include moin
  include ikiwiki
  include pmwiki
  include apache::rails

  apache::site { "images":
    docroot => "${apache_www_folder}/images",
    mpm     => false,
    tag     => 'all',
  }

  # Remove untagged site instances
  Apache::Site <| tag != $hostname and tag != 'all' |> {
    ensure => absent,
  }

  # Remove untagged database instances
  Database::Instance <| tag != $hostname and tag != 'all' |> {
    ensure => absent,
  }

  # Remove untagged ikiwiki instances
  Ikiwiki::Instance <| tag != $hostname and tag != 'all' |> {
    ensure => absent,
  }
}

class websites::hosting::admin inherits websites::setup {
  # Include the needed classes for admin interfaces
  include trac
  include gitweb
}

class websites::dev::setup inherits websites::setup {
  # Include the needed classes for website development
  include php
  include drupal
}