Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/discourse/manifests/init.pp

Issue 4924880143253504: Issue 2471 - Update our Discourse instance (Closed)
Patch Set: Check out correct revision Created May 12, 2015, 10:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « modules/discourse/files/init-discourse ('k') | modules/discourse/templates/discourse.conf.erb » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 $hg_revision = 'd31d28147381'
9 $git_revision = '8a3a02421a39f53b6adf3ca9a6fdba73f42bc932'
10 $ruby_version = '2.1.2'
11 $postgresql_version = '9.3'
12
13 class { 'postgresql::globals':
14 manage_package_repo => true,
15 version => $postgresql_version,
16 }->
8 class {"postgresql::server":} 17 class {"postgresql::server":}
9 18
19 class {"postgresql::server::contrib":
20 package_ensure => 'present',
21 }
22
10 postgresql::server::database {'discourse':} 23 postgresql::server::database {'discourse':}
11 24
12 postgresql::server::role {'discourse': 25 postgresql::server::role {'discourse':
13 password_hash => postgresql_password('discourse', $database_password), 26 password_hash => postgresql_password('discourse', $database_password),
14 db => 'discourse', 27 db => 'discourse',
15 login => true, 28 login => true,
16 superuser => true, 29 superuser => true,
17 require => Postgresql::Server::Database['discourse'] 30 require => Postgresql::Server::Database['discourse']
18 } 31 }
19 32
20 $basic_dependencies = ['postgresql-contrib', 'redis-server', 'ruby1.9.1', 33 $rvm_dependencies = ['curl', 'git-core', 'patch', 'build-essential', 'bison',
21 'libjemalloc1', 'curl'] 34 'zlib1g-dev', 'libssl-dev', 'libxml2-dev', 'sqlite3', 'libsqlite3-dev',
22 $gem_dependencies = ['git', 'build-essential', 'ruby1.9.1-dev', 'libxml2-dev', 35 'autotools-dev', 'libxslt1-dev', 'libyaml-0-2', 'autoconf', 'automake',
23 'libxslt-dev', 'libpq-dev'] 36 'libreadline6-dev', 'libyaml-dev', 'libtool', 'libgdbm-dev',
37 'libncurses5-dev', 'libffi-dev', 'pkg-config', 'gawk']
38 $discourse_dependencies = ['redis-server', 'libjemalloc1']
39 $gem_dependencies = ['libpq-dev']
24 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', 40 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim',
25 'libjpeg-progs', 'optipng', 'pngcrush'] 41 'libjpeg-progs', 'optipng', 'pngcrush']
26 $image_sorcery_dependencies = 'imagemagick' 42 $image_sorcery_dependencies = 'imagemagick'
27 43
28 package {[$basic_dependencies, $gem_dependencies, $image_optim_dependencies, $ image_sorcery_dependencies]: 44 package {[$rvm_dependencies, $discourse_dependencies, $gem_dependencies, $imag e_optim_dependencies, $image_sorcery_dependencies]:
29 ensure => present 45 ensure => present
30 } 46 }
31 47
32 Exec {path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin'} 48 Exec <| tag == 'rvm' |> {
33 49 path => '/home/discourse/.rvm/bin:/usr/local/bin:/usr/bin:/bin',
34 exec {'update-alternatives --set ruby "/usr/bin/ruby1.9.1"': 50 user => discourse,
35 unless => 'test $(readlink "/etc/alternatives/ruby") == "/usr/bin/ruby1.9.1" ', 51 group => www-data,
36 require => Package['ruby1.9.1'] 52 environment => ['HOME=/home/discourse'],
37 } 53 }
38 54
39 exec {'update-alternatives --set gem "/usr/bin/gem1.9.1"': 55 exec {'install-rvm-key':
40 unless => 'test $(readlink "/etc/alternatives/gem") == "/usr/bin/gem1.9.1"', 56 command => 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C2754 62A1703113804BB82D39DC0E3',
41 require => Package['ruby1.9.1'], 57 tag => 'rvm',
42 before => Exec['update_gem'] 58 unless => 'gpg --list-keys | grep D39DC0E3',
43 } 59 }
44 60
45 exec {'update_gem': 61 exec {'install-rvm':
46 command => '/usr/bin/gem update --system 1.8.25', 62 command => 'curl -sSL https://get.rvm.io | bash -s stable',
47 unless => 'test $(gem -v) == "1.8.25"', 63 tag => 'rvm',
48 environment => 'REALLY_GEM_UPDATE_SYSTEM=1', 64 creates => '/home/discourse/.rvm',
65 timeout => 0,
66 logoutput => true,
67 require => [Exec['install-rvm-key'], Package[$rvm_dependencies]],
49 } 68 }
50 69
51 package {'bundler': 70 exec {'install-ruby':
52 ensure => present, 71 command => "rvm install $ruby_version && rvm default do rvm --default use $r uby_version",
53 provider => gem, 72 tag => 'rvm',
54 require => Exec['update_gem'] 73 unless => "rvm list | grep $ruby_version",
mathias 2015/05/26 10:02:16 Please use shellquote() to ensure $ruby_version ca
Wladimir Palant 2015/05/26 10:41:17 Given that $ruby_version is a constant set above,
mathias 2015/05/26 10:54:36 Indeed, it should be done there as well. And yes
74 timeout => 0,
75 logoutput => true,
76 notify => Exec['init-discourse'],
77 require => Exec['install-rvm'],
78 }
79
80 exec {'install-bundler':
81 command => 'rvm default do gem install bundler',
82 tag => 'rvm',
83 unless => 'rvm default do gem list | grep "^bundler "',
84 require => Exec['install-ruby'],
55 } 85 }
56 86
57 file {'/opt/discourse': 87 file {'/opt/discourse':
58 ensure => directory, 88 ensure => directory,
59 mode => 755, 89 mode => 755,
60 owner => discourse, 90 owner => discourse,
61 group => www-data 91 group => www-data
62 } 92 }
63 93
64 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: 94 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']:
65 ensure => directory, 95 ensure => directory,
66 mode => 755, 96 mode => 755,
67 owner => discourse, 97 owner => discourse,
68 group => www-data, 98 group => www-data,
69 require => Exec['fetch-discourse'] 99 require => Exec['fetch-discourse']
70 } 100 }
71 101
72 file {'/opt/discourse/config/discourse.conf': 102 file {'/opt/discourse/config/discourse.conf':
73 mode => 600, 103 mode => 600,
74 owner => discourse, 104 owner => discourse,
75 group => www-data, 105 group => www-data,
76 content => template('discourse/discourse.conf.erb'), 106 content => template('discourse/discourse.conf.erb'),
77 notify => Service['discourse'], 107 notify => Service['discourse'],
78 require => Exec['fetch-discourse'] 108 require => Exec['update-discourse']
79 } 109 }
80 110
81 file {'/usr/local/bin/init-discourse': 111 file {'/usr/local/bin/init-discourse':
82 mode => 0755, 112 mode => 0755,
83 owner => root, 113 owner => root,
84 group => root, 114 group => root,
85 source => 'puppet:///modules/discourse/init-discourse' 115 source => 'puppet:///modules/discourse/init-discourse'
86 } 116 }
87 117
88 user {'discourse': 118 user {'discourse':
89 ensure => present, 119 ensure => present,
90 comment => 'Discourse user', 120 comment => 'Discourse user',
91 home => '/home/discourse', 121 home => '/home/discourse',
92 gid => www-data, 122 gid => www-data,
93 password => '*', 123 password => '*',
94 managehome => true 124 managehome => true
95 } 125 }
96 126
97 file {'/etc/sudoers.d/discourse': 127 file {'/etc/sudoers.d/discourse':
98 ensure => present, 128 ensure => present,
99 owner => root, 129 owner => root,
100 group => root, 130 group => root,
101 mode => 0440, 131 mode => 0440,
102 source => 'puppet:///modules/discourse/sudoers', 132 source => 'puppet:///modules/discourse/sudoers',
103 require => User['discourse'] 133 require => User['discourse']
104 } 134 }
105 135
106 exec {'fetch-discourse': 136 exec {'fetch-discourse':
107 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", 137 command => 'hg clone --noupdate https://hg.adblockplus.org/discourse /opt/di scourse',
108 path => ["/usr/bin/", "/bin/"], 138 path => ["/usr/bin/", "/bin/"],
109 user => discourse, 139 user => discourse,
110 group => www-data, 140 group => www-data,
141 timeout => 0,
111 require => [Package['mercurial'], File['/opt/discourse']], 142 require => [Package['mercurial'], File['/opt/discourse']],
112 notify => Exec['/usr/local/bin/init-discourse'],
113 onlyif => "test ! -d /opt/discourse/.hg" 143 onlyif => "test ! -d /opt/discourse/.hg"
114 } 144 }
115 145
116 exec {'/usr/local/bin/init-discourse': 146 exec {'update-discourse':
147 command => "hg update -R /opt/discourse --clean -r $hg_revision",
148 unless => "hg id -R /opt/discourse | grep $hg_revision",
149 path => ["/usr/bin/", "/bin/"],
150 user => discourse,
151 group => www-data,
152 notify => Exec['init-discourse'],
153 require => Exec['fetch-discourse'],
154 }
155
156 file {'/opt/discourse/config/version.rb':
157 ensure => present,
158 owner => discourse,
159 group => www-data,
160
161 # This is hardcoded here so that Discourse doesn't try to extract it from
162 # the repository. Ideally, we should update it when updating Discourse.
163 content => "\$git_version = '$git_revision'",
164 require => Exec['update-discourse'],
165 before => Exec['init-discourse'],
166 }
167
168 exec {'init-discourse':
169 command => 'rvm default do /usr/local/bin/init-discourse',
170 tag => 'rvm',
117 subscribe => File['/usr/local/bin/init-discourse'], 171 subscribe => File['/usr/local/bin/init-discourse'],
118 refreshonly => true, 172 refreshonly => true,
119 environment => ["AIRBRAKE_KEY=${airbrake_key}"],
120 user => discourse,
121 group => www-data,
122 timeout => 0, 173 timeout => 0,
123 logoutput => true, 174 logoutput => true,
124 require => [Package['bundler', $gem_dependencies], 175 require => [Exec['install-bundler'],
176 Package[$discourse_dependencies, $gem_dependencies],
125 User['discourse'], File['/etc/sudoers.d/discourse'], 177 User['discourse'], File['/etc/sudoers.d/discourse'],
126 Exec['fetch-discourse'], 178 Exec['update-discourse'],
127 File['/opt/discourse/config/discourse.conf'], 179 File['/opt/discourse/config/discourse.conf'],
128 Postgresql::Server::Role['discourse']] 180 Postgresql::Server::Role['discourse']]
129 } 181 }
130 182
131 Discourse::Sitesetting <| |> { 183 Discourse::Sitesetting <| |> {
132 require => Exec['/usr/local/bin/init-discourse'] 184 require => Exec['init-discourse']
133 } 185 }
134 186
135 discourse::sitesetting {'title': 187 discourse::sitesetting {'title':
136 ensure => present, 188 ensure => present,
137 type => 1, 189 type => 1,
138 value => 'Adblock Plus internal discussions' 190 value => 'Adblock Plus internal discussions'
139 } 191 }
140 192
141 discourse::sitesetting {'notification_email': 193 discourse::sitesetting {'notification_email':
142 ensure => present, 194 ensure => present,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 type => 5, 261 type => 5,
210 value => 'f' 262 value => 'f'
211 } 263 }
212 264
213 discourse::sitesetting {'enable_local_account_create': 265 discourse::sitesetting {'enable_local_account_create':
214 ensure => present, 266 ensure => present,
215 type => 5, 267 type => 5,
216 value => 'f' 268 value => 'f'
217 } 269 }
218 270
271 discourse::sitesetting {'enable_google_logins':
272 ensure => present,
273 type => 5,
274 value => 'f'
275 }
276
277 discourse::sitesetting {'enable_google_oauth2_logins':
278 ensure => present,
279 type => 5,
280 value => 't'
281 }
282
283 discourse::sitesetting {'google_oauth2_client_id':
284 ensure => present,
285 type => 1,
286 value => $google_client_id
287 }
288
289 discourse::sitesetting {'google_oauth2_client_secret':
290 ensure => present,
291 type => 1,
292 value => $google_client_secret
293 }
294
219 discourse::sitesetting {'enable_facebook_logins': 295 discourse::sitesetting {'enable_facebook_logins':
220 ensure => present, 296 ensure => present,
221 type => 5, 297 type => 5,
222 value => 'f' 298 value => 'f'
223 } 299 }
224 300
225 discourse::sitesetting {'enable_twitter_logins': 301 discourse::sitesetting {'enable_twitter_logins':
226 ensure => present, 302 ensure => present,
227 type => 5, 303 type => 5,
228 value => 'f' 304 value => 'f'
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ensure => present, 338 ensure => present,
263 type => 3, 339 type => 3,
264 value => '50', 340 value => '50',
265 } 341 }
266 342
267 Discourse::Customservice <| |> { 343 Discourse::Customservice <| |> {
268 user => 'discourse', 344 user => 'discourse',
269 workdir => '/opt/discourse', 345 workdir => '/opt/discourse',
270 env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000', 346 env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000',
271 'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'], 347 'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'],
272 require => Exec['/usr/local/bin/init-discourse'] 348 require => Exec['init-discourse']
273 } 349 }
274 350
275 discourse::customservice {'discourse': 351 discourse::customservice {'discourse':
276 command => 'bundle exec config/unicorn_launcher -c config/unicorn.conf.rb', 352 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'], 353 require => File['/opt/discourse/tmp/pids'],
278 } 354 }
279 355
280 discourse::customservice {'sidekiq': 356 discourse::customservice {'sidekiq':
281 command => 'bundle exec sidekiq' 357 command => '/home/discourse/.rvm/bin/rvm default do bundle exec sidekiq'
282 } 358 }
283 359
284 class {'nginx': 360 class {'nginx':
285 worker_processes => 1, 361 worker_processes => 1,
286 worker_connections => 500 362 worker_connections => 500
287 } 363 }
288 364
289 nginx::hostconfig{$domain: 365 nginx::hostconfig{$domain:
290 source => 'puppet:///modules/discourse/site.conf', 366 source => 'puppet:///modules/discourse/site.conf',
291 global_config => ' 367 global_config => '
292 upstream discourse { 368 upstream discourse {
293 server localhost:3000; 369 server localhost:3000;
294 }', 370 }',
295 is_default => $is_default, 371 is_default => $is_default,
296 certificate => $certificate, 372 certificate => $certificate,
297 private_key => $private_key, 373 private_key => $private_key,
298 log => 'access_log_intraforum' 374 log => 'access_log_intraforum'
299 } 375 }
300 } 376 }
OLDNEW
« no previous file with comments | « modules/discourse/files/init-discourse ('k') | modules/discourse/templates/discourse.conf.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld