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

Powered by Google App Engine
This is Rietveld