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:
parent
4a14a332fa
commit
ae8714d7f1
@ -183,7 +183,9 @@ node 'lists.openstack.org' {
|
|||||||
|
|
||||||
node 'paste.openstack.org' {
|
node 'paste.openstack.org' {
|
||||||
class { 'openstack_project::paste':
|
class { 'openstack_project::paste':
|
||||||
sysadmins => hiera('sysadmins'),
|
db_host => hiera('paste_db_password'),
|
||||||
|
db_password => hiera('paste_db_host'),
|
||||||
|
sysadmins => hiera('sysadmins'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@ class lodgeit {
|
|||||||
'python-pybabel',
|
'python-pybabel',
|
||||||
'python-werkzeug',
|
'python-werkzeug',
|
||||||
'python-simplejson',
|
'python-simplejson',
|
||||||
'python-pygments',
|
'python-pygments']
|
||||||
'drizzle']
|
|
||||||
|
|
||||||
include apache
|
include apache
|
||||||
|
|
||||||
@ -39,24 +38,10 @@ class lodgeit {
|
|||||||
ensure => directory,
|
ensure => directory,
|
||||||
}
|
}
|
||||||
|
|
||||||
service { 'drizzle':
|
|
||||||
ensure => running,
|
|
||||||
hasrestart => true,
|
|
||||||
require => Package['drizzle'],
|
|
||||||
}
|
|
||||||
|
|
||||||
vcsrepo { '/tmp/lodgeit-main':
|
vcsrepo { '/tmp/lodgeit-main':
|
||||||
ensure => latest,
|
ensure => latest,
|
||||||
provider => git,
|
provider => git,
|
||||||
source => 'https://git.openstack.org/openstack-infra/lodgeit',
|
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',
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
define lodgeit::site(
|
define lodgeit::site(
|
||||||
$port,
|
$port,
|
||||||
|
$db_password,
|
||||||
|
$db_host='locahost',
|
||||||
|
$db_user=$name,
|
||||||
$vhost_name="paste.${name}.org",
|
$vhost_name="paste.${name}.org",
|
||||||
$image='') {
|
$image='') {
|
||||||
|
|
||||||
@ -49,35 +52,20 @@ define lodgeit::site(
|
|||||||
content => template('lodgeit/layout.html.erb'),
|
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}":
|
cron { "update_backup_${name}":
|
||||||
user => root,
|
ensure => absent,
|
||||||
hour => 6,
|
user => root,
|
||||||
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}\""
|
|
||||||
|
mysql_backup::backup_remote { $name:
|
||||||
|
database_host => $db_host,
|
||||||
|
database_user => $db_user,
|
||||||
|
database_password => $db_password,
|
||||||
}
|
}
|
||||||
|
|
||||||
service { "${name}-paste":
|
service { "${name}-paste":
|
||||||
ensure => running,
|
ensure => running,
|
||||||
provider => upstart,
|
provider => upstart,
|
||||||
require => [Service['drizzle', 'apache2'], Exec["create_database_${name}"]],
|
require => Service['apache2'],
|
||||||
subscribe => Service['drizzle'],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ from lodgeit import local
|
|||||||
from lodgeit.application import make_app
|
from lodgeit.application import make_app
|
||||||
from lodgeit.database import session
|
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'
|
SECRET_KEY = 'no secret key'
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# == Class: openstack_project::paste
|
# == Class: openstack_project::paste
|
||||||
#
|
#
|
||||||
class openstack_project::paste (
|
class openstack_project::paste (
|
||||||
|
$db_host,
|
||||||
|
$db_password,
|
||||||
$sysadmins = []
|
$sysadmins = []
|
||||||
) {
|
) {
|
||||||
class { 'openstack_project::server':
|
class { 'openstack_project::server':
|
||||||
@ -9,11 +11,9 @@ class openstack_project::paste (
|
|||||||
}
|
}
|
||||||
include lodgeit
|
include lodgeit
|
||||||
lodgeit::site { 'openstack':
|
lodgeit::site { 'openstack':
|
||||||
port => '5000',
|
db_host => $db_host,
|
||||||
image => 'header-bg2.png',
|
db_password => $db_password,
|
||||||
}
|
port => '5000',
|
||||||
|
image => 'header-bg2.png',
|
||||||
lodgeit::site { 'drizzle':
|
|
||||||
port => '5001',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user