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 4a14a332fa
commit ae8714d7f1
5 changed files with 23 additions and 48 deletions

View File

@ -183,7 +183,9 @@ node 'lists.openstack.org' {
node 'paste.openstack.org' {
class { 'openstack_project::paste':
sysadmins => hiera('sysadmins'),
db_host => hiera('paste_db_password'),
db_password => hiera('paste_db_host'),
sysadmins => hiera('sysadmins'),
}
}

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'

View File

@ -1,6 +1,8 @@
# == Class: openstack_project::paste
#
class openstack_project::paste (
$db_host,
$db_password,
$sysadmins = []
) {
class { 'openstack_project::server':
@ -9,11 +11,9 @@ class openstack_project::paste (
}
include lodgeit
lodgeit::site { 'openstack':
port => '5000',
image => 'header-bg2.png',
}
lodgeit::site { 'drizzle':
port => '5001',
db_host => $db_host,
db_password => $db_password,
port => '5000',
image => 'header-bg2.png',
}
}