Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 | |
8 class { 'postgresql::globals': | 13 class { 'postgresql::globals': |
9 manage_package_repo => true, | 14 manage_package_repo => true, |
10 version => '9.3', | 15 version => $postgresql_version, |
11 }-> | 16 }-> |
12 class {"postgresql::server":} | 17 class {"postgresql::server":} |
18 | |
19 class {"postgresql::server::contrib": | |
20 package_ensure => 'present', | |
21 } | |
13 | 22 |
14 postgresql::server::database {'discourse':} | 23 postgresql::server::database {'discourse':} |
15 | 24 |
16 postgresql::server::role {'discourse': | 25 postgresql::server::role {'discourse': |
17 password_hash => postgresql_password('discourse', $database_password), | 26 password_hash => postgresql_password('discourse', $database_password), |
18 db => 'discourse', | 27 db => 'discourse', |
19 login => true, | 28 login => true, |
20 superuser => true, | 29 superuser => true, |
21 require => Postgresql::Server::Database['discourse'] | 30 require => Postgresql::Server::Database['discourse'] |
22 } | 31 } |
23 | 32 |
24 $basic_dependencies = ['redis-server', 'libjemalloc1', 'curl', 'libyaml-dev'] | 33 $rvm_dependencies = ['curl', 'git-core', 'patch', 'build-essential', 'bison', |
25 $gem_dependencies = ['git', 'build-essential', 'libxml2-dev', | 34 'zlib1g-dev', 'libssl-dev', 'libxml2-dev', 'sqlite3', 'libsqlite3-dev', |
26 'libxslt-dev', 'libpq-dev'] | 35 'autotools-dev', 'libxslt1-dev', 'libyaml-0-2', 'autoconf', 'automake', |
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'] | |
27 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', | 40 $image_optim_dependencies = ['advancecomp', 'gifsicle', 'jhead', 'jpegoptim', |
28 'libjpeg-progs', 'optipng', 'pngcrush'] | 41 'libjpeg-progs', 'optipng', 'pngcrush'] |
29 $image_sorcery_dependencies = 'imagemagick' | 42 $image_sorcery_dependencies = 'imagemagick' |
30 | 43 |
31 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]: |
32 ensure => present | 45 ensure => present |
33 } | 46 } |
34 | 47 |
35 Exec <| tag == 'rvm' |> { | 48 Exec <| tag == 'rvm' |> { |
36 path => '/bin:/usr/bin:/usr/sbin:/usr/local/bin:/home/discourse/.rvm/bin', | 49 path => '/home/discourse/.rvm/bin:/usr/local/bin:/usr/bin:/bin', |
37 user => discourse, | 50 user => discourse, |
38 group => www-data, | 51 group => www-data, |
39 environment => ['HOME=/home/discourse'], | 52 environment => ['HOME=/home/discourse'], |
40 } | 53 } |
41 | 54 |
42 exec {'install-rvm-key': | 55 exec {'install-rvm-key': |
43 command => 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C2754 62A1703113804BB82D39DC0E3', | 56 command => 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C2754 62A1703113804BB82D39DC0E3', |
44 tag => 'rvm', | 57 tag => 'rvm', |
45 unless => 'gpg --list-keys | grep D39DC0E3', | 58 unless => 'gpg --list-keys | grep D39DC0E3', |
46 } | 59 } |
47 | 60 |
61 exec {'install-rvm': | |
62 command => 'curl -sSL https://get.rvm.io | bash -s stable', | |
63 tag => 'rvm', | |
64 creates => '/home/discourse/.rvm', | |
65 timeout => 0, | |
66 logoutput => true, | |
67 require => [Exec['install-rvm-key'], Package[$rvm_dependencies]], | |
68 } | |
69 | |
48 exec {'install-ruby': | 70 exec {'install-ruby': |
49 command => 'curl -sSL https://get.rvm.io | bash -s stable --ruby=2.1.2', | 71 command => "rvm install $ruby_version && rvm default do rvm --default use $r uby_version", |
50 tag => 'rvm', | 72 tag => 'rvm', |
51 creates => '/home/discourse/.rvm', | 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
| |
52 require => [Exec['install-rvm-key'], Package[$basic_dependencies]], | 74 timeout => 0, |
75 logoutput => true, | |
76 notify => Exec['init-discourse'], | |
77 require => Exec['install-rvm'], | |
53 } | 78 } |
54 | 79 |
55 exec {'install-bundler': | 80 exec {'install-bundler': |
56 command => 'rvm default do gem install bundler', | 81 command => 'rvm default do gem install bundler', |
57 tag => 'rvm', | 82 tag => 'rvm', |
58 unless => 'rvm default do gem list | grep "^bundler ")', | 83 unless => 'rvm default do gem list | grep "^bundler "', |
59 require => Exec['install-ruby'], | 84 require => Exec['install-ruby'], |
60 } | 85 } |
61 | 86 |
62 file {'/opt/discourse': | 87 file {'/opt/discourse': |
63 ensure => directory, | 88 ensure => directory, |
64 mode => 755, | 89 mode => 755, |
65 owner => discourse, | 90 owner => discourse, |
66 group => www-data | 91 group => www-data |
67 } | 92 } |
68 | 93 |
69 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: | 94 file {['/opt/discourse/tmp', '/opt/discourse/tmp/pids']: |
70 ensure => directory, | 95 ensure => directory, |
71 mode => 755, | 96 mode => 755, |
72 owner => discourse, | 97 owner => discourse, |
73 group => www-data, | 98 group => www-data, |
74 require => Exec['fetch-discourse'] | 99 require => Exec['fetch-discourse'] |
75 } | 100 } |
76 | 101 |
77 file {'/opt/discourse/config/discourse.conf': | 102 file {'/opt/discourse/config/discourse.conf': |
78 mode => 600, | 103 mode => 600, |
79 owner => discourse, | 104 owner => discourse, |
80 group => www-data, | 105 group => www-data, |
81 content => template('discourse/discourse.conf.erb'), | 106 content => template('discourse/discourse.conf.erb'), |
82 notify => Service['discourse'], | 107 notify => Service['discourse'], |
83 require => Exec['fetch-discourse'] | 108 require => Exec['update-discourse'] |
84 } | 109 } |
85 | 110 |
86 file {'/usr/local/bin/init-discourse': | 111 file {'/usr/local/bin/init-discourse': |
87 mode => 0755, | 112 mode => 0755, |
88 owner => root, | 113 owner => root, |
89 group => root, | 114 group => root, |
90 source => 'puppet:///modules/discourse/init-discourse' | 115 source => 'puppet:///modules/discourse/init-discourse' |
91 } | 116 } |
92 | 117 |
93 user {'discourse': | 118 user {'discourse': |
94 ensure => present, | 119 ensure => present, |
95 comment => 'Discourse user', | 120 comment => 'Discourse user', |
96 home => '/home/discourse', | 121 home => '/home/discourse', |
97 gid => www-data, | 122 gid => www-data, |
98 password => '*', | 123 password => '*', |
99 managehome => true | 124 managehome => true |
100 } | 125 } |
101 | 126 |
102 file {'/etc/sudoers.d/discourse': | 127 file {'/etc/sudoers.d/discourse': |
103 ensure => present, | 128 ensure => present, |
104 owner => root, | 129 owner => root, |
105 group => root, | 130 group => root, |
106 mode => 0440, | 131 mode => 0440, |
107 source => 'puppet:///modules/discourse/sudoers', | 132 source => 'puppet:///modules/discourse/sudoers', |
108 require => User['discourse'] | 133 require => User['discourse'] |
109 } | 134 } |
110 | 135 |
111 exec {'fetch-discourse': | 136 exec {'fetch-discourse': |
112 command => "hg clone https://hg.adblockplus.org/discourse /opt/discourse", | 137 command => 'hg clone --noupdate https://hg.adblockplus.org/discourse /opt/di scourse', |
113 path => ["/usr/bin/", "/bin/"], | 138 path => ["/usr/bin/", "/bin/"], |
114 user => discourse, | 139 user => discourse, |
115 group => www-data, | 140 group => www-data, |
141 timeout => 0, | |
116 require => [Package['mercurial'], File['/opt/discourse']], | 142 require => [Package['mercurial'], File['/opt/discourse']], |
143 onlyif => "test ! -d /opt/discourse/.hg" | |
144 } | |
145 | |
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, | |
117 notify => Exec['init-discourse'], | 152 notify => Exec['init-discourse'], |
118 onlyif => "test ! -d /opt/discourse/.hg" | 153 require => Exec['fetch-discourse'], |
119 } | |
120 | |
121 file {'/opt/discourse/config/initializers/airbrake.rb': | |
122 ensure => absent, | |
123 before => Exec['init-discourse'], | |
124 } | 154 } |
125 | 155 |
126 file {'/opt/discourse/config/version.rb': | 156 file {'/opt/discourse/config/version.rb': |
127 ensure => present, | 157 ensure => present, |
128 owner => discourse, | 158 owner => discourse, |
129 group => www-data, | 159 group => www-data, |
130 | 160 |
131 # This is hardcoded here so that Discourse doesn't try to extract it from | 161 # This is hardcoded here so that Discourse doesn't try to extract it from |
132 # the repository. Ideally, we should update it when updating Discourse. | 162 # the repository. Ideally, we should update it when updating Discourse. |
133 content => '$git_version = "8a3a02421a39f53b6adf3ca9a6fdba73f42bc932"', | 163 content => "\$git_version = '$git_revision'", |
164 require => Exec['update-discourse'], | |
134 before => Exec['init-discourse'], | 165 before => Exec['init-discourse'], |
135 } | 166 } |
136 | 167 |
137 exec {'init-discourse': | 168 exec {'init-discourse': |
138 command => 'rvm default do /usr/local/bin/init-discourse', | 169 command => 'rvm default do /usr/local/bin/init-discourse', |
139 tag => 'rvm', | 170 tag => 'rvm', |
140 subscribe => File['/usr/local/bin/init-discourse'], | 171 subscribe => File['/usr/local/bin/init-discourse'], |
141 refreshonly => true, | 172 refreshonly => true, |
142 timeout => 0, | 173 timeout => 0, |
143 logoutput => true, | 174 logoutput => true, |
144 require => [Exec['install-bundler'], | 175 require => [Exec['install-bundler'], |
145 Package['postgresql-server', $gem_dependencies], | 176 Package[$discourse_dependencies, $gem_dependencies], |
146 User['discourse'], File['/etc/sudoers.d/discourse'], | 177 User['discourse'], File['/etc/sudoers.d/discourse'], |
147 Exec['fetch-discourse'], | 178 Exec['update-discourse'], |
148 File['/opt/discourse/config/discourse.conf'], | 179 File['/opt/discourse/config/discourse.conf'], |
149 Postgresql::Server::Role['discourse']] | 180 Postgresql::Server::Role['discourse']] |
150 } | 181 } |
151 | 182 |
152 Discourse::Sitesetting <| |> { | 183 Discourse::Sitesetting <| |> { |
153 require => Exec['init-discourse'] | 184 require => Exec['init-discourse'] |
154 } | 185 } |
155 | 186 |
156 discourse::sitesetting {'title': | 187 discourse::sitesetting {'title': |
157 ensure => present, | 188 ensure => present, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 global_config => ' | 367 global_config => ' |
337 upstream discourse { | 368 upstream discourse { |
338 server localhost:3000; | 369 server localhost:3000; |
339 }', | 370 }', |
340 is_default => $is_default, | 371 is_default => $is_default, |
341 certificate => $certificate, | 372 certificate => $certificate, |
342 private_key => $private_key, | 373 private_key => $private_key, |
343 log => 'access_log_intraforum' | 374 log => 'access_log_intraforum' |
344 } | 375 } |
345 } | 376 } |
LEFT | RIGHT |