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