OLD | NEW |
1 class discourse inherits private::discourse { | 1 class discourse( |
| 2 $domain, |
| 3 $is_default = false |
| 4 ) inherits private::discourse { |
| 5 |
2 include postgresql::server | 6 include postgresql::server |
3 | 7 |
4 postgresql::database {'discourse':} | 8 postgresql::database {'discourse':} |
5 | 9 |
6 postgresql::role {'discourse': | 10 postgresql::role {'discourse': |
7 password_hash => $database_password, | 11 password_hash => $database_password, |
8 db => 'discourse', | 12 db => 'discourse', |
9 login => true, | 13 login => true, |
10 superuser => true, | 14 superuser => true, |
11 require => Postgresql::Database['discourse'] | 15 require => Postgresql::Database['discourse'] |
12 } | 16 } |
13 | 17 |
14 package {['postgresql-contrib', 'redis-server', 'ruby1.9.1']: | 18 $basic_dependencies = ['postgresql-contrib', 'redis-server', 'ruby1.9.1', |
| 19 'libjemalloc1', 'curl'] |
| 20 $gem_dependencies = ['git', 'build-essential', 'ruby1.9.1-dev', 'libxml2-dev', |
| 21 'libxslt-dev', 'libpq-dev'] |
| 22 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', |
| 23 'libjpeg-progs', 'optipng', 'pngcrush'] |
| 24 $image_sorcery_dependencies = 'imagemagick' |
| 25 |
| 26 package {[$basic_dependencies, $gem_dependencies, $image_optim_dependencies, $
image_sorcery_dependencies]: |
15 ensure => present | 27 ensure => present |
16 } | 28 } |
17 | 29 |
18 Exec {path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin'} | 30 Exec {path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin'} |
19 | 31 |
20 exec {'update-alternatives --set ruby "/usr/bin/ruby1.9.1"': | 32 exec {'update-alternatives --set ruby "/usr/bin/ruby1.9.1"': |
21 unless => 'test $(readlink "/etc/alternatives/ruby") == "/usr/bin/ruby1.9.1"
', | 33 unless => 'test $(readlink "/etc/alternatives/ruby") == "/usr/bin/ruby1.9.1"
', |
22 require => Package['ruby1.9.1'] | 34 require => Package['ruby1.9.1'] |
23 } | 35 } |
24 | 36 |
25 exec {'update-alternatives --set gem "/usr/bin/gem1.9.1"': | 37 exec {'update-alternatives --set gem "/usr/bin/gem1.9.1"': |
26 unless => 'test $(readlink "/etc/alternatives/gem") == "/usr/bin/gem1.9.1"', | 38 unless => 'test $(readlink "/etc/alternatives/gem") == "/usr/bin/gem1.9.1"', |
27 require => Package['ruby1.9.1'], | 39 require => Package['ruby1.9.1'], |
28 before => Package['bundler'] | 40 before => Exec['update_gem'] |
| 41 } |
| 42 |
| 43 exec {'update_gem': |
| 44 command => '/usr/bin/gem update --system 1.8.25', |
| 45 unless => 'test $(gem -v) == "1.8.25"', |
| 46 environment => 'REALLY_GEM_UPDATE_SYSTEM=1', |
29 } | 47 } |
30 | 48 |
31 package {'bundler': | 49 package {'bundler': |
32 ensure => present, | 50 ensure => present, |
33 provider => gem | 51 provider => gem, |
| 52 require => Exec['update_gem'] |
34 } | 53 } |
35 | 54 |
36 $gem_dependencies = ['git', 'build-essential', 'ruby1.9.1-dev', 'libxml2-dev', | |
37 'libxslt-dev', 'libpq-dev'] | |
38 package {$gem_dependencies: ensure => present} | |
39 | |
40 file {'/opt/discourse': | 55 file {'/opt/discourse': |
41 ensure => directory, | 56 ensure => directory, |
42 mode => 755, | 57 mode => 755, |
43 owner => discourse, | 58 owner => discourse, |
44 group => www-data | 59 group => www-data |
45 } | 60 } |
46 | 61 |
47 file {'/opt/discourse/config/database.yml': | 62 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: |
| 63 ensure => directory, |
| 64 mode => 755, |
| 65 owner => discourse, |
| 66 group => www-data, |
| 67 require => Exec['fetch-discourse'] |
| 68 } |
| 69 |
| 70 file {'/opt/discourse/config/discourse.conf': |
48 mode => 600, | 71 mode => 600, |
49 owner => discourse, | 72 owner => discourse, |
50 group => www-data, | 73 group => www-data, |
51 content => template('discourse/database.yml.erb'), | 74 content => template('discourse/discourse.conf.erb'), |
52 notify => Service['discourse-thin'], | 75 notify => Service['discourse'], |
53 require => Exec['fetch-discourse'] | |
54 } | |
55 | |
56 file {'/opt/discourse/config/redis.yml': | |
57 mode => 600, | |
58 owner => discourse, | |
59 group => www-data, | |
60 source => 'puppet:///modules/discourse/redis.yml', | |
61 notify => Service['discourse-thin'], | |
62 require => Exec['fetch-discourse'] | 76 require => Exec['fetch-discourse'] |
63 } | 77 } |
64 | 78 |
65 file {'/usr/local/bin/init-discourse': | 79 file {'/usr/local/bin/init-discourse': |
66 mode => 0755, | 80 mode => 0755, |
67 owner => root, | 81 owner => root, |
68 group => root, | 82 group => root, |
69 source => 'puppet:///modules/discourse/init-discourse' | 83 source => 'puppet:///modules/discourse/init-discourse' |
70 } | 84 } |
71 | 85 |
(...skipping 14 matching lines...) Expand all Loading... |
86 source => 'puppet:///modules/discourse/sudoers', | 100 source => 'puppet:///modules/discourse/sudoers', |
87 require => User['discourse'] | 101 require => User['discourse'] |
88 } | 102 } |
89 | 103 |
90 exec {'fetch-discourse': | 104 exec {'fetch-discourse': |
91 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", | 105 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", |
92 path => ["/usr/bin/", "/bin/"], | 106 path => ["/usr/bin/", "/bin/"], |
93 user => discourse, | 107 user => discourse, |
94 group => www-data, | 108 group => www-data, |
95 require => [Package['mercurial'], File['/opt/discourse']], | 109 require => [Package['mercurial'], File['/opt/discourse']], |
| 110 notify => Exec['/usr/local/bin/init-discourse'], |
96 onlyif => "test ! -d /opt/discourse/.hg" | 111 onlyif => "test ! -d /opt/discourse/.hg" |
97 } | 112 } |
98 | 113 |
99 exec {'/usr/local/bin/init-discourse': | 114 exec {'/usr/local/bin/init-discourse': |
100 subscribe => File['/usr/local/bin/init-discourse'], | 115 subscribe => File['/usr/local/bin/init-discourse'], |
101 refreshonly => true, | 116 refreshonly => true, |
102 environment => ["DISCOURSE_SECRET=${secret}", "AIRBRAKE_KEY=${airbrake_key}"
], | 117 environment => ["AIRBRAKE_KEY=${airbrake_key}"], |
103 user => discourse, | 118 user => discourse, |
104 group => www-data, | 119 group => www-data, |
105 timeout => 0, | 120 timeout => 0, |
106 logoutput => true, | 121 logoutput => true, |
107 require => [Package['bundler', 'postgresql-contrib', $gem_dependencies], | 122 require => [Package['bundler', $gem_dependencies], |
108 User['discourse'], File['/etc/sudoers.d/discourse'], | 123 User['discourse'], File['/etc/sudoers.d/discourse'], |
109 Exec['fetch-discourse'], | 124 Exec['fetch-discourse'], |
110 File['/opt/discourse/config/database.yml'], | 125 File['/opt/discourse/config/discourse.conf'], |
111 File['/opt/discourse/config/redis.yml'], | |
112 Postgresql::Role['discourse']] | 126 Postgresql::Role['discourse']] |
113 } | 127 } |
114 | 128 |
115 Discourse::Sitesetting <| |> { | 129 Discourse::Sitesetting <| |> { |
116 require => Exec['/usr/local/bin/init-discourse'] | 130 require => Exec['/usr/local/bin/init-discourse'] |
117 } | 131 } |
118 | 132 |
119 discourse::sitesetting {'title': | 133 discourse::sitesetting {'title': |
120 ensure => present, | 134 ensure => present, |
121 type => 1, | 135 type => 1, |
122 value => 'Adblock Plus internal discussions' | 136 value => 'Adblock Plus internal discussions' |
123 } | 137 } |
124 | 138 |
125 discourse::sitesetting {'notification_email': | 139 discourse::sitesetting {'notification_email': |
126 ensure => present, | 140 ensure => present, |
127 type => 1, | 141 type => 1, |
128 value => 'donotreply@adblockplus.org' | 142 value => 'donotreply@adblockplus.org' |
129 } | 143 } |
130 | 144 |
131 discourse::sitesetting {'contact_email': | 145 discourse::sitesetting {'contact_email': |
132 ensure => present, | 146 ensure => present, |
133 type => 1, | 147 type => 1, |
134 value => 'admins@adblockplus.org' | 148 value => 'admins@adblockplus.org' |
135 } | 149 } |
136 | 150 |
| 151 discourse::sitesetting {'site_contact_username': |
| 152 ensure => present, |
| 153 type => 1, |
| 154 value => 'system' |
| 155 } |
| 156 |
137 discourse::sitesetting {'must_approve_users': | 157 discourse::sitesetting {'must_approve_users': |
138 ensure => present, | 158 ensure => present, |
139 type => 5, | 159 type => 5, |
140 value => 'f' | 160 value => 'f' |
141 } | 161 } |
142 | 162 |
143 discourse::sitesetting {'login_required': | 163 discourse::sitesetting {'login_required': |
144 ensure => present, | 164 ensure => present, |
145 type => 5, | 165 type => 5, |
146 value => 't' | 166 value => 't' |
147 } | 167 } |
148 | 168 |
149 discourse::sitesetting {'email_domains_blacklist': | 169 discourse::sitesetting {'email_domains_blacklist': |
150 ensure => present, | 170 ensure => present, |
151 type => 1, | 171 type => 1, |
152 value => '' | 172 value => '' |
153 } | 173 } |
154 | 174 |
155 discourse::sitesetting {'email_domains_whitelist': | 175 discourse::sitesetting {'email_domains_whitelist': |
156 ensure => present, | 176 ensure => present, |
157 type => 1, | 177 type => 1, |
158 value => 'adblockplus.org|eyeo.com' | 178 value => 'adblockplus.org|eyeo.com' |
159 } | 179 } |
160 | 180 |
161 discourse::sitesetting {'use_ssl': | 181 discourse::sitesetting {'use_https': |
162 ensure => present, | 182 ensure => present, |
163 type => 5, | 183 type => 5, |
164 value => 't' | 184 value => 't' |
165 } | 185 } |
166 | 186 |
167 discourse::sitesetting {'company_full_name': | 187 discourse::sitesetting {'company_full_name': |
168 ensure => present, | 188 ensure => present, |
169 type => 1, | 189 type => 1, |
170 value => 'Eyeo GmbH' | 190 value => 'Eyeo GmbH' |
171 } | 191 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 type => 5, | 237 type => 5, |
218 value => 'f' | 238 value => 'f' |
219 } | 239 } |
220 | 240 |
221 discourse::sitesetting {'enforce_global_nicknames': | 241 discourse::sitesetting {'enforce_global_nicknames': |
222 ensure => present, | 242 ensure => present, |
223 type => 5, | 243 type => 5, |
224 value => 'f' | 244 value => 'f' |
225 } | 245 } |
226 | 246 |
| 247 discourse::sitesetting {'allow_user_locale': |
| 248 ensure => present, |
| 249 type => 5, |
| 250 value => 't' |
| 251 } |
| 252 |
| 253 discourse::sitesetting {'white_listed_spam_host_domains': |
| 254 ensure => present, |
| 255 type => 1, |
| 256 value => 'adblockplus.org,eyeo.com' |
| 257 } |
| 258 |
227 Discourse::Postactiontype <| |> { | 259 Discourse::Postactiontype <| |> { |
228 require => Exec['/usr/local/bin/init-discourse'] | 260 require => Exec['/usr/local/bin/init-discourse'] |
229 } | 261 } |
230 | 262 |
231 discourse::postactiontype {'bookmark': | 263 discourse::postactiontype {'bookmark': |
232 ensure => present, | 264 ensure => present, |
233 id => 1, | 265 id => 1, |
234 position => 1 | 266 position => 1 |
235 } | 267 } |
236 | 268 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 is_flag => true | 300 is_flag => true |
269 } | 301 } |
270 | 302 |
271 discourse::postactiontype {'spam': | 303 discourse::postactiontype {'spam': |
272 ensure => present, | 304 ensure => present, |
273 id => 7, | 305 id => 7, |
274 position => 6, | 306 position => 6, |
275 is_flag => true | 307 is_flag => true |
276 } | 308 } |
277 | 309 |
278 discourse::admin {$admins: | 310 Discourse::Customservice <| |> { |
279 ensure => present, | 311 user => 'discourse', |
| 312 workdir => '/opt/discourse', |
| 313 env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000', |
| 314 'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'], |
280 require => Exec['/usr/local/bin/init-discourse'] | 315 require => Exec['/usr/local/bin/init-discourse'] |
281 } | 316 } |
282 | 317 |
283 Discourse::Customservice <| |> { | 318 discourse::customservice {'discourse': |
284 user => 'discourse', | 319 command => 'bundle exec config/unicorn_launcher -c config/unicorn.conf.rb', |
285 workdir => '/opt/discourse', | 320 require => File['/opt/discourse/tmp/pids'], |
286 env => ['GEM_HOME=~discourse/.gems', 'RAILS_ENV=production', 'RUBY_GC_MALLOC
_LIMIT=90000000'], | |
287 require => Exec['/usr/local/bin/init-discourse'] | |
288 } | |
289 | |
290 discourse::customservice {'discourse-thin': | |
291 command => 'bundle exec thin -S /tmp/discourse-thin.sock start' | |
292 } | 321 } |
293 | 322 |
294 discourse::customservice {'sidekiq': | 323 discourse::customservice {'sidekiq': |
295 command => 'bundle exec sidekiq' | 324 command => 'bundle exec sidekiq' |
296 } | 325 } |
297 | 326 |
298 discourse::customservice {'clockwork': | |
299 command => 'bundle exec clockwork config/clock.rb' | |
300 } | |
301 | |
302 class {'nginx': | 327 class {'nginx': |
303 worker_processes => 1, | 328 worker_processes => 1, |
304 worker_connections => 500 | 329 worker_connections => 500 |
305 } | 330 } |
306 | 331 |
307 file {'/etc/nginx/sites-available/adblockplus.org_sslcert.key': | 332 file {'/etc/nginx/sites-available/adblockplus.org_sslcert.key': |
308 ensure => file, | 333 ensure => file, |
309 notify => Service['nginx'], | 334 notify => Service['nginx'], |
310 before => Nginx::Hostconfig['intraforum.adblockplus.org'], | 335 before => Nginx::Hostconfig['intraforum.adblockplus.org'], |
311 require => Package['nginx'], | 336 require => Package['nginx'], |
312 source => 'puppet:///modules/private/adblockplus.org_sslcert.key' | 337 source => 'puppet:///modules/private/adblockplus.org_sslcert.key' |
313 } | 338 } |
314 | 339 |
315 file {'/etc/nginx/sites-available/adblockplus.org_sslcert.pem': | 340 file {'/etc/nginx/sites-available/adblockplus.org_sslcert.pem': |
316 ensure => file, | 341 ensure => file, |
317 mode => 0400, | 342 mode => 0400, |
318 notify => Service['nginx'], | 343 notify => Service['nginx'], |
319 before => Nginx::Hostconfig['intraforum.adblockplus.org'], | 344 before => Nginx::Hostconfig[$domain], |
320 require => Package['nginx'], | 345 require => Package['nginx'], |
321 source => 'puppet:///modules/private/adblockplus.org_sslcert.pem' | 346 source => 'puppet:///modules/private/adblockplus.org_sslcert.pem' |
322 } | 347 } |
323 | 348 |
324 nginx::hostconfig{'intraforum.adblockplus.org': | 349 nginx::hostconfig{$domain: |
325 source => 'puppet:///modules/discourse/intraforum.adblockplus.org', | 350 content => template('discourse/site.erb'), |
326 enabled => true | 351 enabled => true |
327 } | 352 } |
328 | 353 |
329 file {'/etc/logrotate.d/nginx_intraforum.adblockplus.org': | 354 file {"/etc/logrotate.d/nginx_$domain": |
330 ensure => file, | 355 ensure => file, |
331 require => Nginx::Hostconfig['intraforum.adblockplus.org'], | 356 require => Nginx::Hostconfig[$domain], |
332 source => 'puppet:///modules/discourse/logrotate' | 357 source => 'puppet:///modules/discourse/logrotate' |
333 } | 358 } |
334 } | 359 } |
OLD | NEW |