1 |
class phpbb { |
2 |
class base { |
3 |
$db = "phpbb" |
4 |
$user = "phpbb" |
5 |
|
6 |
include apache::mod_php |
7 |
|
8 |
package { ["php-gd", |
9 |
"php-xml", |
10 |
"php-zlib", |
11 |
"php-ftp", |
12 |
"php-magickwand", |
13 |
"php-pgsql", |
14 |
"php-ldap", ] : |
15 |
ensure => installed |
16 |
} |
17 |
|
18 |
package { "perl-DBD-Pg": |
19 |
ensure => installed |
20 |
} |
21 |
|
22 |
file { "/usr/local/bin/phpbb_apply_config.pl": |
23 |
ensure => present, |
24 |
owner => root, |
25 |
group => root, |
26 |
mode => 755, |
27 |
source => 'puppet:///modules/phpbb/phpbb_apply_config.pl', |
28 |
} |
29 |
|
30 |
$pgsql_password = extlookup("phpbb_pgsql",'x') |
31 |
postgresql::remote_user { $user: |
32 |
password => $pgsql_password, |
33 |
} |
34 |
|
35 |
$forums_dir = "/var/www/forums/" |
36 |
file { "$forums_dir": |
37 |
ensure => directory, |
38 |
owner => root, |
39 |
group => root, |
40 |
} |
41 |
# TODO add a ssl counterpart |
42 |
# TODO check that everything is locked down |
43 |
apache::vhost_base { "forums.$domain": |
44 |
content => template("phpbb/forums_vhost.conf"), |
45 |
} |
46 |
|
47 |
apache::vhost_base { "ssl_forums.$domain": |
48 |
use_ssl => true, |
49 |
vhost => "forums.$domain", |
50 |
content => template("phpbb/forums_vhost.conf"), |
51 |
} |
52 |
|
53 |
file { "/etc/httpd/conf/vhosts.d/forums.d/": |
54 |
ensure => directory, |
55 |
} |
56 |
|
57 |
} |
58 |
|
59 |
define phpbb_config($key, $value) { |
60 |
exec { "phpbb_apply $name": |
61 |
command => "/usr/local/bin/phpbb_apply_config.pl $key", |
62 |
user => root, |
63 |
environment => ["PGDATABASE=$phpbb::base::database", |
64 |
"PGUSER=$phpbb::base::user", |
65 |
"PGPASSWORD=$phpbb::base::pgsql_password", |
66 |
"PGHOST=pgsql.$domain", |
67 |
"VALUE=$value"], |
68 |
require => File["/usr/local/bin/phpbb_apply_config.pl"], |
69 |
} |
70 |
} |
71 |
|
72 |
define redirection_instance($url) { |
73 |
$lang = $name |
74 |
file { "/etc/httpd/conf/vhosts.d/forums.d/redirect_$name.conf": |
75 |
ensure => present, |
76 |
owner => root, |
77 |
group => root, |
78 |
mode => 644, |
79 |
content => template("phpbb/forums_redirect.conf"), |
80 |
notify => Service['apache'], |
81 |
} |
82 |
} |
83 |
|
84 |
define databases(){ |
85 |
Phpbb::Locale_db <<| |>> |
86 |
} |
87 |
|
88 |
define locale_db($tag = "default", |
89 |
$user = $phpbb::base::user) { |
90 |
postgresql::database { $name: |
91 |
description => "$lang db for phpbb forum", |
92 |
user => $user, |
93 |
tag => $tag, |
94 |
require => Postgresql::User[$user] |
95 |
} |
96 |
} |
97 |
|
98 |
# TODO find a way to avoid all the phpbb::base prefix |
99 |
define instance() { |
100 |
include phpbb::base |
101 |
|
102 |
$lang = $name |
103 |
$database = "${phpbb::base::db}_$lang" |
104 |
|
105 |
$user = $phpbb::base::user |
106 |
$pgsql_password = $phpbb::base::pgsql_password |
107 |
$forums_dir = $phpbb::base::forums_dir |
108 |
|
109 |
include git::client |
110 |
exec { "git_clone $lang": |
111 |
command =>"git clone git://git.$domain/forum/ $lang", |
112 |
cwd => $forums_dir, |
113 |
creates => "$forums_dir/$lang", |
114 |
require => File["$forums_dir"], |
115 |
notify => Exec["rm_install $lang"], |
116 |
} |
117 |
|
118 |
# remove this or the forum will not work ( 'board disabled' ) |
119 |
# maybe it would be better to move this elsehwere, I |
120 |
# am not sure ( and in any case, that's still in git ) |
121 |
exec { "rm_install $lang": |
122 |
command => "rm -Rf $forums_dir/$lang/phpBB/install", |
123 |
onlyif => "test -d $forums_dir/$lang/phpBB/install", |
124 |
} |
125 |
|
126 |
# list found by reading ./install/install_install.php |
127 |
# end of check_server_requirements ( 2 loops ) |
128 |
|
129 |
$writable_dirs = ['cache', |
130 |
'images/avatars/upload', |
131 |
'files', |
132 |
'store' ] |
133 |
|
134 |
$dir_names = regsubst($writable_dirs,'^',"$forums_dir/$lang/phpBB/") |
135 |
|
136 |
file { $dir_names: |
137 |
ensure => directory, |
138 |
owner => apache, |
139 |
group => root, |
140 |
mode => 755, |
141 |
require => Exec["git_clone $lang"], |
142 |
} |
143 |
|
144 |
file { "$forums_dir/$lang/phpBB/config.php": |
145 |
ensure => present, |
146 |
owner => root, |
147 |
group => root, |
148 |
mode => 644, |
149 |
content => template("phpbb/config.php"), |
150 |
} |
151 |
|
152 |
@@phpbb::locale_db { $database: |
153 |
user => $user, |
154 |
} |
155 |
|
156 |
phpbb_config { "ldap_user/$lang": |
157 |
key => "ldap_user", |
158 |
value => "cn=phpbb-$hostname,ou=System Accounts,$dc_suffix", |
159 |
} |
160 |
|
161 |
phpbb_config { "ldap_server/$lang": |
162 |
key => "ldap_server", |
163 |
value => "ldaps://ldap.$domain", |
164 |
} |
165 |
|
166 |
$ldap_password = extlookup("phpbb_ldap",'x') |
167 |
phpbb_config { "ldap_password/$lang": |
168 |
key => "ldap_password", |
169 |
value => $ldap_password, |
170 |
} |
171 |
|
172 |
phpbb_config { "ldap_base_dn/$lang": |
173 |
key => "ldap_base_dn", |
174 |
value => "ou=People,$dc_suffix", |
175 |
} |
176 |
|
177 |
phpbb_config { "auth_method/$lang": |
178 |
key => "auth_method", |
179 |
value => "ldap", |
180 |
} |
181 |
|
182 |
phpbb_config { "ldap_mail/$lang": |
183 |
key => "ldap_mail", |
184 |
value => "mail", |
185 |
} |
186 |
|
187 |
phpbb_config { "ldap_uid/$lang": |
188 |
key => "ldap_mail", |
189 |
value => "uid", |
190 |
} |
191 |
|
192 |
phpbb_config { "cookie_domain/$lang": |
193 |
key => "ldap_mail", |
194 |
value => "forums.$domain", |
195 |
} |
196 |
|
197 |
phpbb_config { "server_name/$lang": |
198 |
key => "ldap_mail", |
199 |
value => "forums.$domain", |
200 |
} |
201 |
|
202 |
|
203 |
} |
204 |
} |