From ae8714d7f1ee60f2bec8fa7b4a373ec64b26f15c Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 2 May 2014 12:25:49 -0700 Subject: [PATCH] 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 --- manifests/site.pp | 4 ++- modules/lodgeit/manifests/init.pp | 17 +-------- modules/lodgeit/manifests/site.pp | 36 +++++++------------- modules/lodgeit/templates/manage.py.erb | 2 +- modules/openstack_project/manifests/paste.pp | 12 +++---- 5 files changed, 23 insertions(+), 48 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index 90519c7340..639bfb0b8c 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -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'), } } diff --git a/modules/lodgeit/manifests/init.pp b/modules/lodgeit/manifests/init.pp index c2da8066bc..a0e18fe879 100644 --- a/modules/lodgeit/manifests/init.pp +++ b/modules/lodgeit/manifests/init.pp @@ -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', - } - } diff --git a/modules/lodgeit/manifests/site.pp b/modules/lodgeit/manifests/site.pp index ec0ecd6751..75d48d45e0 100644 --- a/modules/lodgeit/manifests/site.pp +++ b/modules/lodgeit/manifests/site.pp @@ -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'], } } diff --git a/modules/lodgeit/templates/manage.py.erb b/modules/lodgeit/templates/manage.py.erb index f6af18bd1d..e57e02445b 100644 --- a/modules/lodgeit/templates/manage.py.erb +++ b/modules/lodgeit/templates/manage.py.erb @@ -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' diff --git a/modules/openstack_project/manifests/paste.pp b/modules/openstack_project/manifests/paste.pp index 5d190e83b4..cb52f75c28 100644 --- a/modules/openstack_project/manifests/paste.pp +++ b/modules/openstack_project/manifests/paste.pp @@ -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', } }