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

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

Issue 6155422901731328: Run Rietveld using the AppEngine SDK (Closed)
Patch Set: Addressed comments and added proper configuration Created June 3, 2015, 3:31 p.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/rietveld/files/wrapper.py ('k') | modules/rietveld/templates/settings.py.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 rietveld( 1 class rietveld(
2 $domain, 2 $domain,
3 $certificate, 3 $certificate,
4 $private_key, 4 $private_key,
5 $is_default = false, 5 $is_default = false,
6 $secret_key = hiera('rietveld::secret_key', ''), 6 $secret_key = hiera('rietveld::secret_key', ''),
7 $fixtures = hiera('rietveld::fixtures', {}), 7 $admins = hiera('rietveld::admins', []),
8 $oauth2_client_id = hiera('rietveld::oauth2_client_id', ''),
9 $oauth2_client_secret = hiera('rietveld::oauth2_client_secret', ''),
8 $database = hiera('rietveld::database', { 10 $database = hiera('rietveld::database', {
9 'engine' => 'sqlite3', 11 'engine' => 'sqlite3',
10 'name' => 'dev.db', 12 'name' => 'dev.db',
11 }), 13 }),
12 ) { 14 ) {
13 15
14 include nginx 16 include nginx
15 $django_home = '/home/rietveld/django-gae2django' 17 $rietveld_home = '/opt/rietveld'
16 $rietveld_home = "${django_home}/examples/rietveld"
17 18
18 Exec { 19 Exec {
19 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', 20 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
20 } 21 }
21 22
22 nginx::hostconfig {$domain: 23 nginx::hostconfig {$domain:
23 source => 'puppet:///modules/rietveld/site.conf', 24 source => 'puppet:///modules/rietveld/site.conf',
24 is_default => $is_default, 25 is_default => $is_default,
25 certificate => $certificate, 26 certificate => $certificate,
26 private_key => $private_key, 27 private_key => $private_key,
27 log => 'access_log_codereview' 28 log => 'access_log_codereview'
28 } 29 }
29 30
30 package {['python-django', 'make', 'patch', 'gunicorn']: ensure => present} 31 package {['wget', 'unzip', 'git', 'make', 'patch', 'subversion']: ensure => pr esent}
31 32
32 user {'rietveld': 33 user {'rietveld':
33 ensure => present, 34 ensure => present,
34 comment => 'User of the rietveld installation', 35 comment => 'User of the rietveld installation',
35 home => '/home/rietveld', 36 home => '/home/rietveld',
36 managehome => true 37 managehome => true
37 } 38 }
38 39
39 exec {'get_rietveld': 40 exec {'download_appengine':
40 command => "hg clone https://hg.adblockplus.org/gae2django/ ${django_home}/" , 41 # TODO: We cannot rely on this URL to stay fixed
41 require => Package['mercurial'], 42 command => 'wget -O /home/rietveld/google_appengine.zip https://storage.goog leapis.com/appengine-sdks/featured/google_appengine_1.9.21.zip',
42 user => rietveld, 43 user => 'root',
43 onlyif => "test ! -d ${django_home}", 44 creates => '/home/rietveld/google_appengine.zip',
45 require => [User['rietveld'], Package['wget']],
44 } 46 }
45 47
46 file {"${rietveld_home}/Makefile": 48 exec {'install_appengine':
47 ensure => file, 49 command => 'unzip /home/rietveld/google_appengine.zip -d /opt',
48 owner => rietveld, 50 user => 'root',
49 require => Exec['get_rietveld'], 51 creates => '/opt/google_appengine',
50 source => 'puppet:///modules/rietveld/Makefile', 52 require => [Exec['download_appengine'], Package['unzip']],
51 } 53 }
52 54
53 file {"${rietveld_home}/settings.py": 55 exec {'get_rietveld':
54 ensure => file, 56 command => "git clone https://github.com/rietveld-codereview/rietveld.git $r ietveld_home && cd $rietveld_home && git reset --HARD 87257f5",
55 owner => rietveld, 57 user => 'root',
56 require => Exec['get_rietveld'], 58 require => Package['git'],
57 content => template('rietveld/settings.py.erb'), 59 creates => $rietveld_home,
58 } 60 }
59 61
60 exec {'install_rietveld': 62 exec {'setup_rietveld':
61 command => "make all", 63 command => 'make update_revision mapreduce',
62 cwd => "${rietveld_home}", 64 cwd => $rietveld_home,
63 user => rietveld, 65 user => root,
64 require => [ 66 require => [Exec['get_rietveld'], Package['make', 'patch', 'subversion']],
65 File["${rietveld_home}/Makefile"], 67 creates => "${rietveld_home}/mapreduce",
66 File["${rietveld_home}/settings.py"]],
67 onlyif => "test ! -e ${$rietveld_home}/gae2django",
68 } 68 }
69 69
70 file {'/etc/init/rietveld.conf': 70 file {'/opt/wrappers':
71 ensure => directory,
72 owner => 'root',
73 }
74
75 file {'wrapper.py':
76 path => '/opt/wrappers/wrapper.py',
71 ensure => file, 77 ensure => file,
72 owner => root, 78 owner => 'root',
73 source => 'puppet:///modules/rietveld/rietveld.conf', 79 mode => '0755',
80 source => 'puppet:///modules/rietveld/wrapper.py',
74 notify => Service['rietveld'], 81 notify => Service['rietveld'],
75 } 82 }
76 83
77 file {'/etc/init.d/rietveld': 84 file {'dev_appserver.py':
85 path => '/opt/wrappers/dev_appserver.py',
78 ensure => link, 86 ensure => link,
79 target => '/lib/init/upstart-job', 87 require => File['wrapper.py'],
80 require => [File['/etc/init/rietveld.conf'], Exec['install_rietveld']] 88 target => '/opt/wrappers/wrapper.py',
81 } 89 }
82 90
83 service {'rietveld': 91 file {'_python_runtime.py':
84 ensure => running, 92 path => '/opt/wrappers/_python_runtime.py',
85 hasstatus => false, 93 ensure => link,
86 require => [Package['gunicorn'], File['/etc/init.d/rietveld']] 94 require => File['wrapper.py'],
95 target => '/opt/wrappers/wrapper.py',
87 } 96 }
88 97
89 file {"${rietveld_home}/fixtures": 98 file {'/var/lib/rietveld':
90 ensure => directory, 99 ensure => directory,
91 owner => 'rietveld', 100 owner => 'rietveld',
92 mode => 0750,
93 require => Exec['install_rietveld'],
94 } 101 }
95 102
96 define fixture( 103 file {'config.ini':
97 $ensure = present, 104 path => '/var/lib/rietveld/config.ini',
98 $source = undef, 105 ensure => file,
99 $content = undef, 106 owner => 'root',
100 ) { 107 content => template('rietveld/config.ini.erb'),
101 108 notify => Service['rietveld'],
102 # Note that $script will return EXIT_SUCCESS when the .type is
103 # not recognized - although no action is done then. Thus we enforce
104 # JSON here, which is the default for command "dumpdata" anyway:
105 $script = "${rietveld::rietveld_home}/manage.py"
106 $destination = "${rietveld::rietveld_home}/fixtures/$name.json"
107
108 exec {$destination:
109 command => shellquote($script, 'loaddata', $destination),
110 cwd => $rietveld::rietveld_home,
111 refreshonly => true,
112 user => 'rietveld',
113 }
114
115 file {$destination:
116 ensure => $ensure,
117 content => $content,
118 source => $source,
119 owner => 'rietveld',
120 mode => 0640,
121 notify => $ensure ? {
122 present => Exec[$destination],
123 default => [],
124 }
125 }
126 } 109 }
127 110
128 create_resources(rietveld::fixture, $fixtures) 111 customservice {'rietveld':
112 command => "/opt/wrappers/dev_appserver.py \
113 --skip_sdk_update_check --port 8080 ${rietveld_home}",
114 user => 'rietveld',
115 require => [
116 Exec['install_appengine', 'setup_rietveld'],
117 File['dev_appserver.py', '_python_runtime.py', 'config.ini'],
118 ],
119 }
129 } 120 }
OLDNEW
« no previous file with comments | « modules/rietveld/files/wrapper.py ('k') | modules/rietveld/templates/settings.py.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld