diff --git a/manifests/init.pp b/manifests/init.pp index c2da806..a0e18fe 100644 --- a/manifests/init.pp +++ b/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/manifests/site.pp b/manifests/site.pp index ec0ecd6..75d48d4 100644 --- a/manifests/site.pp +++ b/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/templates/manage.py.erb b/templates/manage.py.erb index f6af18b..e57e024 100644 --- a/templates/manage.py.erb +++ b/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'