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

Unified Diff: modules/discourse/manifests/init.pp

Issue 4924880143253504: Issue 2471 - Update our Discourse instance (Closed)
Patch Set: Created May 8, 2015, 7:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/discourse/manifests/init.pp
===================================================================
--- a/modules/discourse/manifests/init.pp
+++ b/modules/discourse/manifests/init.pp
@@ -1,62 +1,67 @@
class discourse(
$domain,
$certificate,
$private_key,
$is_default = false
) inherits private::discourse {
+ class { 'postgresql::globals':
+ manage_package_repo => true,
+ version => '9.3',
+ }->
class {"postgresql::server":}
postgresql::server::database {'discourse':}
postgresql::server::role {'discourse':
password_hash => postgresql_password('discourse', $database_password),
db => 'discourse',
login => true,
superuser => true,
require => Postgresql::Server::Database['discourse']
}
- $basic_dependencies = ['postgresql-contrib', 'redis-server', 'ruby1.9.1',
- 'libjemalloc1', 'curl']
- $gem_dependencies = ['git', 'build-essential', 'ruby1.9.1-dev', 'libxml2-dev',
+ $basic_dependencies = ['redis-server', 'libjemalloc1', 'curl', 'libyaml-dev']
+ $gem_dependencies = ['git', 'build-essential', 'libxml2-dev',
'libxslt-dev', 'libpq-dev']
$image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim',
'libjpeg-progs', 'optipng', 'pngcrush']
$image_sorcery_dependencies = 'imagemagick'
package {[$basic_dependencies, $gem_dependencies, $image_optim_dependencies, $image_sorcery_dependencies]:
ensure => present
}
- Exec {path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin'}
-
- exec {'update-alternatives --set ruby "/usr/bin/ruby1.9.1"':
- unless => 'test $(readlink "/etc/alternatives/ruby") == "/usr/bin/ruby1.9.1"',
- require => Package['ruby1.9.1']
+ Exec <| tag == 'rvm' |> {
+ path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin:/home/discourse/.rvm/bin',
+ user => discourse,
+ group => www-data,
+ environment => ['HOME=/home/discourse'],
}
- exec {'update-alternatives --set gem "/usr/bin/gem1.9.1"':
- unless => 'test $(readlink "/etc/alternatives/gem") == "/usr/bin/gem1.9.1"',
- require => Package['ruby1.9.1'],
- before => Exec['update_gem']
+ exec {'install-rvm-key':
+ command => 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3',
+ tag => 'rvm',
+ unless => 'gpg --list-keys | grep D39DC0E3',
}
- exec {'update_gem':
- command => '/usr/bin/gem update --system 1.8.25',
- unless => 'test $(gem -v) == "1.8.25"',
- environment => 'REALLY_GEM_UPDATE_SYSTEM=1',
+ exec {'install-ruby':
+ command => 'curl -sSL https://get.rvm.io | bash -s stable --ruby=2.1.2',
+ tag => 'rvm',
+ creates => '/home/discourse/.rvm',
+ require => [Exec['install-rvm-key'], Package[$basic_dependencies]],
}
- package {'bundler':
- ensure => present,
- provider => gem,
- require => Exec['update_gem']
+ exec {'install-bundler':
+ command => 'rvm default do gem install bundler',
+ tag => 'rvm',
+ unless => 'rvm default do gem list | grep "^bundler ")',
+ require => Exec['install-ruby'],
}
file {'/opt/discourse':
ensure => directory,
mode => 755,
owner => discourse,
group => www-data
}
@@ -104,37 +109,53 @@ class discourse(
}
exec {'fetch-discourse':
command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse",
path => ["/usr/bin/", "/bin/"],
user => discourse,
group => www-data,
require => [Package['mercurial'], File['/opt/discourse']],
- notify => Exec['/usr/local/bin/init-discourse'],
+ notify => Exec['init-discourse'],
onlyif => "test ! -d /opt/discourse/.hg"
}
- exec {'/usr/local/bin/init-discourse':
+ file {'/opt/discourse/config/initializers/airbrake.rb':
+ ensure => absent,
+ before => Exec['init-discourse'],
+ }
+
+ file {'/opt/discourse/config/version.rb':
+ ensure => present,
+ owner => discourse,
+ group => www-data,
+
+ # This is hardcoded here so that Discourse doesn't try to extract it from
+ # the repository. Ideally, we should update it when updating Discourse.
+ content => '$git_version = "8a3a02421a39f53b6adf3ca9a6fdba73f42bc932"',
+ before => Exec['init-discourse'],
+ }
+
+ exec {'init-discourse':
+ command => 'rvm default do /usr/local/bin/init-discourse',
+ tag => 'rvm',
subscribe => File['/usr/local/bin/init-discourse'],
refreshonly => true,
- environment => ["AIRBRAKE_KEY=${airbrake_key}"],
- user => discourse,
- group => www-data,
timeout => 0,
logoutput => true,
- require => [Package['bundler', $gem_dependencies],
+ require => [Exec['install-bundler'],
+ Package['postgresql-server', $gem_dependencies],
User['discourse'], File['/etc/sudoers.d/discourse'],
Exec['fetch-discourse'],
File['/opt/discourse/config/discourse.conf'],
Postgresql::Server::Role['discourse']]
}
Discourse::Sitesetting <| |> {
- require => Exec['/usr/local/bin/init-discourse']
+ require => Exec['init-discourse']
}
discourse::sitesetting {'title':
ensure => present,
type => 1,
value => 'Adblock Plus internal discussions'
}
@@ -211,16 +232,40 @@ class discourse(
}
discourse::sitesetting {'enable_local_account_create':
ensure => present,
type => 5,
value => 'f'
}
+ discourse::sitesetting {'enable_google_logins':
+ ensure => present,
+ type => 5,
+ value => 'f'
+ }
+
+ discourse::sitesetting {'enable_google_oauth2_logins':
+ ensure => present,
+ type => 5,
+ value => 't'
+ }
+
+ discourse::sitesetting {'google_oauth2_client_id':
+ ensure => present,
+ type => 1,
+ value => $google_client_id
+ }
+
+ discourse::sitesetting {'google_oauth2_client_secret':
+ ensure => present,
+ type => 1,
+ value => $google_client_secret
+ }
+
discourse::sitesetting {'enable_facebook_logins':
ensure => present,
type => 5,
value => 'f'
}
discourse::sitesetting {'enable_twitter_logins':
ensure => present,
@@ -264,26 +309,26 @@ class discourse(
value => '50',
}
Discourse::Customservice <| |> {
user => 'discourse',
workdir => '/opt/discourse',
env => ['RAILS_ENV=production', 'RUBY_GC_MALLOC_LIMIT=90000000',
'UNICORN_WORKERS=2', 'LD_PRELOAD=/usr/lib/libjemalloc.so.1'],
- require => Exec['/usr/local/bin/init-discourse']
+ require => Exec['init-discourse']
}
discourse::customservice {'discourse':
- command => 'bundle exec config/unicorn_launcher -c config/unicorn.conf.rb',
+ command => '/home/discourse/.rvm/bin/rvm default do bundle exec config/unicorn_launcher -c config/unicorn.conf.rb',
require => File['/opt/discourse/tmp/pids'],
}
discourse::customservice {'sidekiq':
- command => 'bundle exec sidekiq'
+ command => '/home/discourse/.rvm/bin/rvm default do bundle exec sidekiq'
}
class {'nginx':
worker_processes => 1,
worker_connections => 500
}
nginx::hostconfig{$domain:
« 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