Migrate to using trove db for pastebin

The current drizzle-based pastebin has gotten a bit slow. Move to using
remote trove db.

Change-Id: I62fd164af26199fd9ed69770fac73c3e2f6a5344
This commit is contained in:
Monty Taylor 2014-05-02 12:25:49 -07:00
parent 07a23375ad
commit 29f3962220
3 changed files with 14 additions and 41 deletions

View File

@ -6,8 +6,7 @@ class lodgeit {
'python-pybabel',
'python-werkzeug',
'python-simplejson',
'python-pygments',
'drizzle']
'python-pygments']
include apache
@ -39,24 +38,10 @@ class lodgeit {
ensure => directory,
}
service { 'drizzle':
ensure => running,
hasrestart => true,
require => Package['drizzle'],
}
vcsrepo { '/tmp/lodgeit-main':
ensure => latest,
provider => git,
source => 'https://git.openstack.org/openstack-infra/lodgeit',
}
# create initial git DB backup location
exec { 'create_db_backup':
command => 'git init /var/backups/lodgeit_db',
path => '/bin:/usr/bin',
onlyif => 'test ! -d /var/backups/lodgeit_db',
}
}

View File

@ -3,6 +3,9 @@
define lodgeit::site(
$port,
$db_password,
$db_host='locahost',
$db_user=$name,
$vhost_name="paste.${name}.org",
$image='') {
@ -49,35 +52,20 @@ define lodgeit::site(
content => template('lodgeit/layout.html.erb'),
}
exec { "create_database_${name}":
command => "drizzle --user=root -e \"create database if not exists ${name};\"",
path => '/bin:/usr/bin',
unless => 'drizzle --disable-column-names -r --batch -e "show databases like \'openstack\'" | grep -q openstack',
require => Service['drizzle'],
}
# create a backup .sql file in git
exec { "create_db_backup_${name}":
command => "touch ${name}.sql && git add ${name}.sql && git commit -am \"Initial commit for ${name}\"",
cwd => '/var/backups/lodgeit_db/',
path => '/bin:/usr/bin',
onlyif => "test ! -f /var/backups/lodgeit_db/${name}.sql",
}
# cron to take a backup and commit it in git
cron { "update_backup_${name}":
user => root,
hour => 6,
minute => 23,
command => "sleep $((RANDOM\\%60+60)) && cd /var/backups/lodgeit_db && drizzledump -uroot ${name} > ${name}.sql && git commit -qam \"Updating DB backup for ${name}\""
ensure => absent,
user => root,
}
mysql_backup::backup_remote { $name:
database_host => $db_host,
database_user => $db_user,
database_password => $db_password,
}
service { "${name}-paste":
ensure => running,
provider => upstart,
require => [Service['drizzle', 'apache2'], Exec["create_database_${name}"]],
subscribe => Service['drizzle'],
require => Service['apache2'],
}
}

View File

@ -7,7 +7,7 @@ from lodgeit import local
from lodgeit.application import make_app
from lodgeit.database import session
dburi = 'drizzle://127.0.0.1:4427/<%= @name %>'
dburi = 'mysql://<%= @db_user %>:<%= @db_password %>@<%= @db_host %>:3306/<%= @name %>'
SECRET_KEY = 'no secret key'