Index: modules/rietveld/manifests/init.pp |
=================================================================== |
--- a/modules/rietveld/manifests/init.pp |
+++ b/modules/rietveld/manifests/init.pp |
@@ -7,97 +7,127 @@ class rietveld( |
$fixtures = hiera('rietveld::fixtures', {}), |
$database = hiera('rietveld::database', { |
'engine' => 'sqlite3', |
'name' => 'dev.db', |
}), |
) { |
include nginx |
- $django_home = '/home/rietveld/django-gae2django' |
- $rietveld_home = "${django_home}/examples/rietveld" |
+ $rietveld_home = '/opt/rietveld' |
Exec { |
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
} |
nginx::hostconfig {$domain: |
source => 'puppet:///modules/rietveld/site.conf', |
is_default => $is_default, |
certificate => $certificate, |
private_key => $private_key, |
log => 'access_log_codereview' |
} |
- package {['python-django', 'make', 'patch', 'gunicorn']: ensure => present} |
+ package {['wget', 'unzip', 'git', 'make', 'patch', 'subversion']: ensure => present} |
user {'rietveld': |
ensure => present, |
comment => 'User of the rietveld installation', |
home => '/home/rietveld', |
managehome => true |
} |
- exec {'get_rietveld': |
- command => "hg clone https://hg.adblockplus.org/gae2django/ ${django_home}/", |
- require => Package['mercurial'], |
- user => rietveld, |
- onlyif => "test ! -d ${django_home}", |
+ exec {'download_appengine': |
+ # TODO: We cannot rely on this URL to stay fixed |
+ command => 'wget -O /home/rietveld/google_appengine.zip https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.21.zip', |
+ user => 'root', |
+ creates => '/home/rietveld/google_appengine.zip', |
+ require => [User['rietveld'], Package['wget']], |
} |
- file {"${rietveld_home}/Makefile": |
- ensure => file, |
- owner => rietveld, |
- require => Exec['get_rietveld'], |
- source => 'puppet:///modules/rietveld/Makefile', |
+ exec {'install_appengine': |
+ command => 'unzip /home/rietveld/google_appengine.zip -d /opt', |
+ user => 'root', |
+ creates => '/opt/google_appengine', |
+ require => [Exec['download_appengine'], Package['unzip']], |
} |
- file {"${rietveld_home}/settings.py": |
- ensure => file, |
- owner => rietveld, |
- require => Exec['get_rietveld'], |
- content => template('rietveld/settings.py.erb'), |
+ exec {'get_rietveld': |
+ command => "git clone https://github.com/rietveld-codereview/rietveld.git $rietveld_home && cd $rietveld_home && git reset --HARD 87257f5", |
+ user => 'root', |
+ require => Package['git'], |
+ creates => $rietveld_home, |
} |
- exec {'install_rietveld': |
- command => "make all", |
- cwd => "${rietveld_home}", |
- user => rietveld, |
- require => [ |
- File["${rietveld_home}/Makefile"], |
- File["${rietveld_home}/settings.py"]], |
- onlyif => "test ! -e ${$rietveld_home}/gae2django", |
+ exec {'setup_rietveld': |
+ command => 'make update_revision mapreduce', |
+ cwd => $rietveld_home, |
+ user => root, |
+ require => [Exec['get_rietveld'], Package['make', 'patch', 'subversion']], |
+ creates => "${rietveld_home}/mapreduce", |
} |
- file {'/etc/init/rietveld.conf': |
+ file {'/opt/wrappers': |
+ ensure => directory, |
+ owner => 'root', |
+ } |
+ |
+ file {'wrapper.py': |
+ path => '/opt/wrappers/wrapper.py', |
ensure => file, |
- owner => root, |
- source => 'puppet:///modules/rietveld/rietveld.conf', |
+ owner => 'root', |
+ mode => '0755', |
+ source => 'puppet:///modules/rietveld/wrapper.py', |
notify => Service['rietveld'], |
} |
- file {'/etc/init.d/rietveld': |
+ file {'dev_appserver.py': |
+ path => '/opt/wrappers/dev_appserver.py', |
ensure => link, |
- target => '/lib/init/upstart-job', |
- require => [File['/etc/init/rietveld.conf'], Exec['install_rietveld']] |
+ require => File['wrapper.py'], |
+ target => '/opt/wrappers/wrapper.py', |
} |
- service {'rietveld': |
- ensure => running, |
- hasstatus => false, |
- require => [Package['gunicorn'], File['/etc/init.d/rietveld']] |
+ file {'_python_runtime.py': |
+ path => '/opt/wrappers/_python_runtime.py', |
+ ensure => link, |
+ require => File['wrapper.py'], |
+ target => '/opt/wrappers/wrapper.py', |
} |
- file {"${rietveld_home}/fixtures": |
+ file {'/var/lib/rietveld': |
ensure => directory, |
owner => 'rietveld', |
- mode => 0750, |
- require => Exec['install_rietveld'], |
} |
+ file {'cookie_secret': |
+ path => '/var/lib/rietveld/cookie_secret', |
+ ensure => file, |
+ owner => 'root', |
+ content => $secret_key, |
+ notify => Service['rietveld'], |
+ } |
+ |
+ customservice {'rietveld': |
+ command => "/opt/wrappers/dev_appserver.py \ |
+ --skip_sdk_update_check --port 8080 ${rietveld_home}", |
+ user => 'rietveld', |
+ require => [ |
+ Exec['install_appengine', 'setup_rietveld'], |
+ File['dev_appserver.py', '_python_runtime.py', 'cookie_secret'], |
+ ], |
+ } |
+ |
+# file {"${rietveld_home}/fixtures": |
+# ensure => directory, |
+# owner => 'rietveld', |
+# mode => 0750, |
+# require => Exec['install_rietveld'], |
+# } |
+ |
define fixture( |
$ensure = present, |
$source = undef, |
$content = undef, |
) { |
# Note that $script will return EXIT_SUCCESS when the .type is |
# not recognized - although no action is done then. Thus we enforce |
@@ -120,10 +150,10 @@ class rietveld( |
mode => 0640, |
notify => $ensure ? { |
present => Exec[$destination], |
default => [], |
} |
} |
} |
- create_resources(rietveld::fixture, $fixtures) |
+# create_resources(rietveld::fixture, $fixtures) |
} |