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

Delta Between Two Patch Sets: modules/discourse_docker/manifests/init.pp

Issue 29370691: Issue 4234 - New discourse module based on docker (Closed)
Left Patch Set: Created Jan. 3, 2017, 4:42 p.m.
Right Patch Set: add empty line at eof Created Jan. 6, 2017, 3:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « modules/discourse_docker/files/site.conf ('k') | modules/discourse_docker/templates/app.yml.erb » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # == Class: discourse_docker
2 #
3 # Depends on module docker (for now)
4 #
5 # == Parameters:
6
7 # [*domain*]
8 # Set the domain (hostname) for the site. This will be used in both nginx and d iscourse settings.
9 #
10 # [*certificate*]
11 # SSL cert file (in modules/private/files/) for using in nginx.
12 #
13 # [*private_key*]
14 # SSL private key file (in modules/private/files/) for nginx.
15 #
16 # [*site_settings*]
17 # Hash used for discourse configuration. See https://github.com/discourse/disco urse/blob/master/config/site_settings.yml
18 # for all defaults and possible options.
19 #
20 # [*is_default*]
21 # Passed on to nginx (whether or not the site config should be default).
22 #
23 # [*admins*]
24 # Emails of accounts that will be made admin and developer on initial signup.
25 #
26 # [*google_oauth2_client_id*]
27 # Client ID from Google API console - see https://developers.google.com/identit y/protocols/OAuth2 .
28 #
29 # [*google_oauth2_client_secret*]
30 # Secret from Google API console - matching client_id above.
31 #
32 # === Examples:
33 #
34 # class {'discourse_docker':
35 # domain => 'forum.adblockplus.org',
36 # certificate => 'forum.adblockplus.org_sslcert.pem',
37 # private_key => 'forum.adblockplus.org_sslcert.key',
38 # is_default => true,
39 # admins => ['test1@adblockplus.org','test2@adblockplus.org'],
40 # google_oauth2_client_id => '698703124405-3jodbnl423ie9r01gv4j3ve1olg02sv3. apps.googleusercontent.com',
41 # google_oauth2_client_secret => 'tB2ESr1b99qJpbOYqv3PtuPU',
42 # site_settings => {
43 # title => 'Awesome Forum',
44 # # .. many more site settings here...
45 # }
46 # }
47 #
1 class discourse_docker( 48 class discourse_docker(
2 $domain, 49 $domain,
f.lopez 2017/01/03 20:22:45 we need to set default values for these variables,
3 $certificate, 50 $certificate = hiera('discourse_docker::certificate', undef),
4 $private_key, 51 $private_key = hiera('discourse_docker::private_key', undef),
f.lopez 2017/01/03 20:22:45 we might want to add a $ensure variable so we can
5 $site_settings, 52 $site_settings = hiera('discourse_docker::site_settings', {}),
6 $is_default = false, 53 $is_default = hiera('discourse_docker::is_default', false),
7 $admins = hiera('discourse_docker::admins', []) 54 $admins = hiera('discourse_docker::admins', []),
55 $google_oauth2_client_id = hiera('discourse_docker::google_oauth2_client_id', 'undef'),
56 $google_oauth2_client_secret = hiera('discourse_docker::google_oauth2_client_s ecret', 'undef'),
8 ) { 57 ) {
9 58
10 apt::source {'docker': 59 include stdlib
11 before => Package['docker-engine'],
12 location => 'https://apt.dockerproject.org/repo',
13 release => downcase("$::osfamily-$::lsbdistcodename"),
14 include_src => false,
15 key => '58118E89F3A912897C070ADBF76221572C52609D',
16 key_server => 'hkp://ha.pool.sks-keyservers.net:80',
17 }
18 60
19 package {'git': 61 package {'git':
20 ensure => present, 62 ensure => present,
21 }
22
f.lopez 2017/01/03 20:22:45 for these packages we can use the `ensure_resource
23 package {'docker-engine':
24 ensure => 'present',
25 require => Apt::Source['docker'],
26 }
27
28 service {'docker':
29 ensure => running,
30 require => Package['docker-engine'],
31 } 63 }
32 64
33 file {'/var/discourse': 65 file {'/var/discourse':
34 ensure => directory, 66 ensure => directory,
35 mode => 755, 67 mode => 755,
36 owner => root, 68 owner => root,
37 group => root 69 group => root
38 } 70 }
39 71
40 exec {'fetch-discourse-docker': 72 exec {'fetch-discourse-docker':
41 command => "git clone https://github.com/discourse/discourse_docker.git /var /discourse", 73 command => "git clone https://github.com/discourse/discourse_docker.git /var /discourse",
42 path => ["/usr/bin/", "/bin/"], 74 path => ["/usr/bin/", "/bin/"],
43 user => root, 75 user => root,
44 timeout => 0, 76 timeout => 0,
45 require => [Package['git'], File['/var/discourse']], 77 require => [Package['git'], File['/var/discourse']],
46 unless => "test -d /var/discourse/.git" 78 unless => "test -d /var/discourse/.git"
47 } 79 }
48 80
49 file {'/var/discourse/containers/app.yml': 81 file {'/var/discourse/containers/app.yml':
50 ensure => file, 82 ensure => file,
51 mode => 600, 83 mode => 600,
52 owner => root, 84 owner => root,
53 group => root, 85 group => root,
54 content => template('discourse_docker/app.yml.erb'), 86 content => template('discourse_docker/app.yml.erb'),
55 require => Package['docker-engine'], 87 require => Class['docker'],
56 } 88 }
57 89
58 exec {'rebuild': 90 exec {'rebuild':
59 command => '/var/discourse/launcher rebuild app --skip-prereqs', 91 command => '/var/discourse/launcher rebuild app --skip-prereqs',
60 user => root, 92 user => root,
61 subscribe => File['/var/discourse/containers/app.yml'], 93 subscribe => File['/var/discourse/containers/app.yml'],
62 refreshonly => true, 94 refreshonly => true,
63 logoutput => 'on_failure', 95 logoutput => 'on_failure',
64 timeout => 0, 96 timeout => 0,
65 require => [Exec['fetch-discourse-docker'], 97 require => [Exec['fetch-discourse-docker'],
66 Service['docker'], 98 Class['docker'],
67 Package['git']], 99 Package['git']],
68 } 100 }
69 101
70 exec {'start': 102 exec {'start':
71 command => '/var/discourse/launcher start app --skip-prereqs', 103 command => '/var/discourse/launcher start app --skip-prereqs',
72 user => root, 104 user => root,
73 logoutput => 'on_failure', 105 logoutput => 'on_failure',
74 require => Exec['rebuild'], 106 require => Exec['rebuild'],
75 } 107 }
f.lopez 2017/01/03 20:22:45 this can be inside a conditional from `service {'d
76 108
77 class {'nginx':
78 worker_connections => 500
79 }
80
81 nginx::hostconfig {$domain: 109 nginx::hostconfig {$domain:
82 source => 'puppet:///modules/discourse_docker/site.conf', 110 source => "puppet:///modules/discourse_docker/site.conf",
83 is_default => $is_default,
84 certificate => $certificate, 111 certificate => $certificate,
85 private_key => $private_key, 112 private_key => $private_key,
86 log => 'access_log_intraforum' 113 is_default => $is_default,
114 log => "access_log_intraforum"
87 } 115 }
88 } 116 }
117
LEFTRIGHT

Powered by Google App Engine
This is Rietveld