Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7bcce82bb775044b7700f1f721bb95bbec6d15b4 (plain) (blame)
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*******************************************************************************
 * Copyright (c) 2012 Frank Becker and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Frank Becker - initial API and implementation
 *     Steffen Pingel (Tasktop Techologies)
 *******************************************************************************/
class bugzilla {
  $userOwner = "tools"
  $userGroup = "tools"
  $bugzillaBase = "/home/$userOwner/bugzilla"
  $dbuser = 'bugz'
  $dbuserPassword = 'ovlwq8'
  $envhost = regsubst(file("/etc/hostname"), '\n', '')
  $confDir = "$bugzillaBase/conf.d"

  exec { "apt-get update":
    command => "apt-get update",
    onlyif  => "find /var/lib/apt/lists/ -mtime -7 | (grep -q Package; [ $? != 0 ])",
  }

  $requirements = [
    "apache2-mpm-prefork",
    "apache2",
    "build-essential",
    "emacs",
    "git-core",
    "language-pack-en",
    "libapache2-mod-auth-mysql",
    "libapache2-mod-fcgid",
    "libapache2-mod-perl2-dev",
    "libapache2-mod-perl2",
    "libapache2-mod-php5",
    "libappconfig-perl",
    "libauthen-radius-perl",
    "libauthen-sasl-perl",
    "libcgi-pm-perl",
    "libchart-perl",
    "libdaemon-generic-perl",
    "libdate-calc-perl",
    "libdatetime-perl",
    "libdatetime-timezone-perl",
    "libdbd-mysql-perl",
    "libdbi-perl",
    "libemail-mime-modifier-perl",
    "libemail-mime-perl",
    "libemail-send-perl",
    "libencode-detect-perl",
    "libfile-slurp-perl",
    "libgd-graph-perl",
    "libhtml-scrubber-perl",
    "libjson-rpc-perl",
    "libmail-sendmail-perl",
    "libmath-random-isaac-perl",
    "libmath-random-isaac-xs-perl",
    "libmime-perl",
    "libmodule-build-perl",
    "libnet-ldap-perl",
    "libsoap-lite-perl",
    "libtemplate-perl-doc",
    "libtemplate-perl",
    "libtemplate-plugin-gd-perl",
    "libtest-taint-perl",
    "libtheschwartz-perl",
    "libxml-perl",
    "libxml-twig-perl",
    "make",
    "mysql-server",
    "patchutils",
    "perl-doc",
    "perlmagick",
    "php5-mysql",
    "php5",
    "phpmyadmin",
    "puppet",
    "cpanminus"
    ]
    

  package { $requirements:
    ensure  => "installed",
    require => Exec["apt-get update"],
  }

  exec { "Enable php5 module":
    command => "a2enmod php5",
    require => Package["libapache2-mod-php5"],
    creates => "/etc/apache2/mods-enabled/php5.load",
  }

  service { "apache2":
    ensure  => running,
    require => Package["apache2"],
  }

  exec { "Enable auth_digest module":
    command => "a2enmod auth_digest",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/auth_digest.load",
  }

  exec { "Enable fcgid module":
    command => "a2enmod fcgid",
    require => Package["libapache2-mod-fcgid"],
    creates => "/etc/apache2/mods-enabled/fcgid.load",
  }

  exec { "Enable proxy mod":
    command => "a2enmod proxy",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/proxy.load",
  }

  exec { "Enable proxy_http mod":
    command => "a2enmod proxy_http",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/proxy_http.load",
  }

  exec { "Enable ssl module":
    command => "a2enmod ssl",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/ssl.load",
  }
  
  exec { "Enable rewrite module":
    command => "a2enmod rewrite",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/rewrite.load",
  }
  
  exec { "Enable cgi module":
    command => "a2enmod cgi",
    require => Package["apache2"],
    creates => "/etc/apache2/mods-enabled/cgi.load",
  }

  service { "mysql":
    ensure  => "running",
    enable  => true,
    require => Package["mysql-server"],
  }

  exec { "phpmyadmin_Apache2":
    command => "echo '#phpmyadmin\nInclude /etc/phpmyadmin/apache.conf' >>/etc/apache2/apache2.conf",
    require => [Package["phpmyadmin"], Package["libapache2-mod-php5"]],
    unless  => 'cat /etc/apache2/apache2.conf | grep "#phpmyadmin"'
  }

/* lvps92-51-163-75.dedicated.hosteurope.de is the actual hostname for mylyn.org 
   so we not show the mysql admin for that suite 
*/
 if $envhost != "lvps92-51-163-75.dedicated.hosteurope.de"{
    file { "$bugzillaBase/servicephpmyadmin.json":
      source  => "puppet:///modules/bugzilla/servicephpmyadmin.json",		
      owner   => "$userOwner",
      group   => "$userGroup",
      mode    => 644,
      require => Package[$requirements],
    }
  }

  file { "/usr/lib/cgi-bin/services":		
    source  => "puppet:///modules/bugzilla/services.cgi",		
    mode => 755,		
    require => Package[$requirements],
  }

  $_exists =inline_template("<%= File.exists?('/etc/bugzilla_clear_mode') %>")
  if $_exists == "true"  {
    $clearMode            = regsubst(file("/etc/bugzilla_clear_mode"), '\n', '')
  } else {
    $clearMode            = "noclear"
    exec { "create clearMode":
      command => "echo \"noclear\" >/etc/bugzilla_clear_mode",
      creates => '/etc/bugzilla_clear_mode',
    }
  }

  exec { "create  $confDir":
    command => "mkdir -p $confDir",
    creates => "$confDir",
    user => "$userOwner",
    require => Package[$requirements],
  }

  exec { "mysql create user ${dbuser}":
    unless   => "/usr/bin/mysql --user='${dbuser}' --password='${dbuserPassword}'",
    command   => "/usr/bin/mysql -v --user='root' -e \"CREATE USER '${dbuser}'@localhost IDENTIFIED BY '${dbuserPassword}'\"",
    logoutput => true,
    require   => Package["mysql-server"],
  }

  exec { "prepare bugzilla":
    command => "cpanm CGI; cpanm DBI; cpanm DateTime::TimeZone; cpanm Email::Sender;echo Bugzilla pre-requisites are installed",
    require => [Exec["mysql create user ${dbuser}"],Exec["create  $confDir"]],
  }

}

Back to the top