OLD | NEW |
1 class discourse( | 1 class discourse( |
2 $domain, | 2 $domain, |
3 $certificate, | 3 $certificate, |
4 $private_key, | 4 $private_key, |
5 $is_default = false | 5 $is_default = false |
6 ) inherits private::discourse { | 6 ) inherits private::discourse { |
7 | 7 |
| 8 class { 'postgresql::globals': |
| 9 manage_package_repo => true, |
| 10 version => '9.3', |
| 11 }-> |
8 class {"postgresql::server":} | 12 class {"postgresql::server":} |
9 | 13 |
| 14 class {"postgresql::server::contrib": |
| 15 package_ensure => 'present', |
| 16 } |
| 17 |
10 postgresql::server::database {'discourse':} | 18 postgresql::server::database {'discourse':} |
11 | 19 |
12 postgresql::server::role {'discourse': | 20 postgresql::server::role {'discourse': |
13 password_hash => postgresql_password('discourse', $database_password), | 21 password_hash => postgresql_password('discourse', $database_password), |
14 db => 'discourse', | 22 db => 'discourse', |
15 login => true, | 23 login => true, |
16 superuser => true, | 24 superuser => true, |
17 require => Postgresql::Server::Database['discourse'] | 25 require => Postgresql::Server::Database['discourse'] |
18 } | 26 } |
19 | 27 |
20 $basic_dependencies = ['postgresql-contrib', 'redis-server', 'ruby1.9.1', | 28 $rvm_dependencies = ['curl', 'git-core', 'patch', 'build-essential', 'bison', |
21 'libjemalloc1', 'curl'] | 29 'zlib1g-dev', 'libssl-dev', 'libxml2-dev', 'sqlite3', 'libsqlite3-dev', |
22 $gem_dependencies = ['git', 'build-essential', 'ruby1.9.1-dev', 'libxml2-dev', | 30 'autotools-dev', 'libxslt1-dev', 'libyaml-0-2', 'autoconf', 'automake', |
23 'libxslt-dev', 'libpq-dev'] | 31 'libreadline6-dev', 'libyaml-dev', 'libtool', 'libgdbm-dev', |
| 32 'libncurses5-dev', 'libffi-dev', 'pkg-config', 'gawk'] |
| 33 $discourse_dependencies = ['redis-server', 'libjemalloc1'] |
| 34 $gem_dependencies = ['libpq-dev'] |
24 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', | 35 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', |
25 'libjpeg-progs', 'optipng', 'pngcrush'] | 36 'libjpeg-progs', 'optipng', 'pngcrush'] |
26 $image_sorcery_dependencies = 'imagemagick' | 37 $image_sorcery_dependencies = 'imagemagick' |
27 | 38 |
28 package {[$basic_dependencies, $gem_dependencies, $image_optim_dependencies, $
image_sorcery_dependencies]: | 39 package {[$rvm_dependencies, $discourse_dependencies, $gem_dependencies, $imag
e_optim_dependencies, $image_sorcery_dependencies]: |
29 ensure => present | 40 ensure => present |
30 } | 41 } |
31 | 42 |
32 Exec {path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin'} | 43 Exec <| tag == 'rvm' |> { |
33 | 44 path => '/home/discourse/.rvm/bin:/usr/local/bin:/usr/bin:/bin', |
34 exec {'update-alternatives --set ruby "/usr/bin/ruby1.9.1"': | 45 user => discourse, |
35 unless => 'test $(readlink "/etc/alternatives/ruby") == "/usr/bin/ruby1.9.1"
', | 46 group => www-data, |
36 require => Package['ruby1.9.1'] | 47 environment => ['HOME=/home/discourse'], |
37 } | 48 } |
38 | 49 |
39 exec {'update-alternatives --set gem "/usr/bin/gem1.9.1"': | 50 exec {'install-rvm-key': |
40 unless => 'test $(readlink "/etc/alternatives/gem") == "/usr/bin/gem1.9.1"', | 51 command => 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C2754
62A1703113804BB82D39DC0E3', |
41 require => Package['ruby1.9.1'], | 52 tag => 'rvm', |
42 before => Exec['update_gem'] | 53 unless => 'gpg --list-keys | grep D39DC0E3', |
43 } | 54 } |
44 | 55 |
45 exec {'update_gem': | 56 exec {'install-rvm': |
46 command => '/usr/bin/gem update --system 1.8.25', | 57 command => 'curl -sSL https://get.rvm.io | bash -s stable', |
47 unless => 'test $(gem -v) == "1.8.25"', | 58 tag => 'rvm', |
48 environment => 'REALLY_GEM_UPDATE_SYSTEM=1', | 59 creates => '/home/discourse/.rvm', |
| 60 timeout => 0, |
| 61 logoutput => true, |
| 62 require => [Exec['install-rvm-key'], Package[$rvm_dependencies]], |
49 } | 63 } |
50 | 64 |
51 package {'bundler': | 65 exec {'install-ruby': |
52 ensure => present, | 66 command => 'rvm install 2.1.2 && rvm default do rvm --default use 2.1.2', |
53 provider => gem, | 67 tag => 'rvm', |
54 require => Exec['update_gem'] | 68 unless => 'rvm list | grep 2.1.2', |
| 69 timeout => 0, |
| 70 logoutput => true, |
| 71 notify => Exec['init-discourse'], |
| 72 require => Exec['install-rvm'], |
| 73 } |
| 74 |
| 75 exec {'install-bundler': |
| 76 command => 'rvm default do gem install bundler', |
| 77 tag => 'rvm', |
| 78 unless => 'rvm default do gem list | grep "^bundler "', |
| 79 require => Exec['install-ruby'], |
55 } | 80 } |
56 | 81 |
57 file {'/opt/discourse': | 82 file {'/opt/discourse': |
58 ensure => directory, | 83 ensure => directory, |
59 mode => 755, | 84 mode => 755, |
60 owner => discourse, | 85 owner => discourse, |
61 group => www-data | 86 group => www-data |
62 } | 87 } |
63 | 88 |
64 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: | 89 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 mode => 0440, | 126 mode => 0440, |
102 source => 'puppet:///modules/discourse/sudoers', | 127 source => 'puppet:///modules/discourse/sudoers', |
103 require => User['discourse'] | 128 require => User['discourse'] |
104 } | 129 } |
105 | 130 |
106 exec {'fetch-discourse': | 131 exec {'fetch-discourse': |
107 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", | 132 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", |
108 path => ["/usr/bin/", "/bin/"], | 133 path => ["/usr/bin/", "/bin/"], |
109 user => discourse, | 134 user => discourse, |
110 group => www-data, | 135 group => www-data, |
| 136 timeout => 0, |
111 require => [Package['mercurial'], File['/opt/discourse']], | 137 require => [Package['mercurial'], File['/opt/discourse']], |
112 notify => Exec['/usr/local/bin/init-discourse'], | 138 notify => Exec['init-discourse'], |
113 onlyif => "test ! -d /opt/discourse/.hg" | 139 onlyif => "test ! -d /opt/discourse/.hg" |
114 } | 140 } |
115 | 141 |
116 exec {'/usr/local/bin/init-discourse': | 142 file {'/opt/discourse/config/initializers/airbrake.rb': |
| 143 ensure => absent, |
| 144 before => Exec['init-discourse'], |
| 145 } |
| 146 |
| 147 file {'/opt/discourse/config/version.rb': |
| 148 ensure => present, |
| 149 owner => discourse, |
| 150 group => www-data, |
| 151 |
| 152 # This is hardcoded here so that Discourse doesn't try to extract it from |
| 153 # the repository. Ideally, we should update it when updating Discourse. |
| 154 content => '$git_version = "8a3a02421a39f53b6adf3ca9a6fdba73f42bc932"', |
| 155 require => Exec['fetch-discourse'], |
| 156 before => Exec['init-discourse'], |
| 157 } |
| 158 |
| 159 exec {'init-discourse': |
| 160 command => 'rvm default do /usr/local/bin/init-discourse', |
| 161 tag => 'rvm', |
117 subscribe => File['/usr/local/bin/init-discourse'], | 162 subscribe => File['/usr/local/bin/init-discourse'], |
118 refreshonly => true, | 163 refreshonly => true, |
119 environment => ["AIRBRAKE_KEY=${airbrake_key}"], | |
120 user => discourse, | |
121 group => www-data, | |
122 timeout => 0, | 164 timeout => 0, |
123 logoutput => true, | 165 logoutput => true, |
124 require => [Package['bundler', $gem_dependencies], | 166 require => [Exec['install-bundler'], |
| 167 Package[$discourse_dependencies, $gem_dependencies], |
125 User['discourse'], File['/etc/sudoers.d/discourse'], | 168 User['discourse'], File['/etc/sudoers.d/discourse'], |
126 Exec['fetch-discourse'], | 169 Exec['fetch-discourse'], |
127 File['/opt/discourse/config/discourse.conf'], | 170 File['/opt/discourse/config/discourse.conf'], |
128 Postgresql::Server::Role['discourse']] | 171 Postgresql::Server::Role['discourse']] |
129 } | 172 } |
130 | 173 |
131 Discourse::Sitesetting <| |> { | 174 Discourse::Sitesetting <| |> { |
132 require => Exec['/usr/local/bin/init-discourse'] | 175 require => Exec['init-discourse'] |
133 } | 176 } |
134 | 177 |
135 discourse::sitesetting {'title': | 178 discourse::sitesetting {'title': |
136 ensure => present, | 179 ensure => present, |
137 type => 1, | 180 type => 1, |
138 value => 'Adblock Plus internal discussions' | 181 value => 'Adblock Plus internal discussions' |
139 } | 182 } |
140 | 183 |
141 discourse::sitesetting {'notification_email': | 184 discourse::sitesetting {'notification_email': |
142 ensure => present, | 185 ensure => present, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 type => 5, | 252 type => 5, |
210 value => 'f' | 253 value => 'f' |
211 } | 254 } |
212 | 255 |
213 discourse::sitesetting {'enable_local_account_create': | 256 discourse::sitesetting {'enable_local_account_create': |
214 ensure => present, | 257 ensure => present, |
215 type => 5, | 258 type => 5, |
216 value => 'f' | 259 value => 'f' |
217 } | 260 } |
218 | 261 |
| 262 discourse::sitesetting {'enable_google_logins': |
| 263 ensure => present, |
| 264 type => 5, |
| 265 value => 'f' |
| 266 } |
| 267 |
| 268 discourse::sitesetting {'enable_google_oauth2_logins': |
| 269 ensure => present, |
| 270 type => 5, |
| 271 value => 't' |
| 272 } |
| 273 |
| 274 discourse::sitesetting {'google_oauth2_client_id': |
| 275 ensure => present, |
| 276 type => 1, |
| 277 value => $google_client_id |
| 278 } |
| 279 |
| 280 discourse::sitesetting {'google_oauth2_client_secret': |
| 281 ensure => present, |
| 282 type => 1, |
| 283 value => $google_client_secret |
| 284 } |
| 285 |
219 discourse::sitesetting {'enable_facebook_logins': | 286 discourse::sitesetting {'enable_facebook_logins': |
220 ensure => present, | 287 ensure => present, |
221 type => 5, | 288 type => 5, |
222 value => 'f' | 289 value => 'f' |
223 } | 290 } |
224 | 291 |
225 discourse::sitesetting {'enable_twitter_logins': | 292 discourse::sitesetting {'enable_twitter_logins': |
226 ensure => present, | 293 ensure => present, |
227 type => 5, | 294 type => 5, |
228 value => 'f' | 295 value => 'f' |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 ensure => present, | 329 ensure => present, |
263 type => 3, | 330 type => 3, |
264 value => '50', | 331 value => '50', |
265 } | 332 } |
266 | 333 |
267 Discourse::Customservice <| |> { | 334 Discourse::Customservice <| |> { |
268 user => 'discourse', | 335 user => 'discourse', |
269 workdir => '/opt/discourse', | 336 workdir => '/opt/discourse', |
270 env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000', | 337 env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000', |
271 'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'], | 338 'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'], |
272 require => Exec['/usr/local/bin/init-discourse'] | 339 require => Exec['init-discourse'] |
273 } | 340 } |
274 | 341 |
275 discourse::customservice {'discourse': | 342 discourse::customservice {'discourse': |
276 command => 'bundle exec config/unicorn_launcher -c config/unicorn.conf.rb', | 343 command => '/home/discourse/.rvm/bin/rvm default do bundle exec config/unico
rn_launcher -c config/unicorn.conf.rb', |
277 require => File['/opt/discourse/tmp/pids'], | 344 require => File['/opt/discourse/tmp/pids'], |
278 } | 345 } |
279 | 346 |
280 discourse::customservice {'sidekiq': | 347 discourse::customservice {'sidekiq': |
281 command => 'bundle exec sidekiq' | 348 command => '/home/discourse/.rvm/bin/rvm default do bundle exec sidekiq' |
282 } | 349 } |
283 | 350 |
284 class {'nginx': | 351 class {'nginx': |
285 worker_processes => 1, | 352 worker_processes => 1, |
286 worker_connections => 500 | 353 worker_connections => 500 |
287 } | 354 } |
288 | 355 |
289 nginx::hostconfig{$domain: | 356 nginx::hostconfig{$domain: |
290 source => 'puppet:///modules/discourse/site.conf', | 357 source => 'puppet:///modules/discourse/site.conf', |
291 global_config => ' | 358 global_config => ' |
292 upstream discourse { | 359 upstream discourse { |
293 server localhost:3000; | 360 server localhost:3000; |
294 }', | 361 }', |
295 is_default => $is_default, | 362 is_default => $is_default, |
296 certificate => $certificate, | 363 certificate => $certificate, |
297 private_key => $private_key, | 364 private_key => $private_key, |
298 log => 'access_log_intraforum' | 365 log => 'access_log_intraforum' |
299 } | 366 } |
300 } | 367 } |
OLD | NEW |