From 27ecc02cab697c18137d1fd2043e8b1db6a22d0a Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 5 Sep 2013 18:22:21 -0700 Subject: [PATCH] Update etherpad and etherpad puppet manifests. * manifests/site.pp: Pass new mysql DB variables to openstack::etherpad*. * modules/etherpad_lite/manifests/apache.pp: Fix broken /etc/ssl/certs permissions (0700 -> 0755). * modules/etherpad_lite/manifests/init.pp: Update default nodejs and etherpad versions. Remove ep_headings plugin install. New plugin define should be used for this instead. Stop making the etherpad-lite ref to checkout optional (defaults to develop). Note these changes are probably not going to be backward compat. * modules/etherpad_lite/manifests/plugin.pp: Define to install etherpad lite plugins. * modules/etherpad_lite/manifests/site.pp: Simplify DB support and remove support for the dirty DB type. * modules/etherpad_lite/templates/etherpad-lite_settings.json.erb: Bring settings erb up to par with latest template. * modules/etherpad_lite/templates/etherpadlite.vhost.erb: Update rewrite rules for new etherpad. Instead of allowing nice pad urls rooted at / redirect these url to /p/padname. Etherpad does not deal well with a change in root path as /p/ is hardcoded in many places. * modules/openstack_project/manifests/etherpad.pp * modules/openstack_project/manifests/etherpad_dev.pp: Update to use new etherpad module setup. MySQL DBs are now externally managed, pass in needed connection info. * modules/mysql_backup/manifests/backup_remote.pp: New define to backup remote DB servers. * modules/mysql_backup/templates/my.cnf.erb: Template for a my.cnf to be used by the cron in backup_remote.pp. Allows for easy connectivity from server using MySQL DB as root. Change-Id: I1250297674b91e81d59cd28c07c52e09967ca548 --- manifests/backup.pp | 6 ++++ manifests/backup_remote.pp | 67 ++++++++++++++++++++++++++++++++++++++ templates/my.cnf.erb | 4 +++ 3 files changed, 77 insertions(+) create mode 100644 manifests/backup_remote.pp create mode 100644 templates/my.cnf.erb diff --git a/manifests/backup.pp b/manifests/backup.pp index 7b31679..585621d 100644 --- a/manifests/backup.pp +++ b/manifests/backup.pp @@ -26,6 +26,12 @@ define mysql_backup::backup ( } } + if ! defined(Package['mysql-client']) { + package { 'mysql-client': + ensure => present, + } + } + cron { "${name}-backup": ensure => present, command => "/usr/bin/mysqldump --defaults-file=${defaults_file} --opt --ignore-table mysql.event --all-databases | gzip -9 > ${dest_dir}/${name}.sql.gz", diff --git a/manifests/backup_remote.pp b/manifests/backup_remote.pp new file mode 100644 index 0000000..257c363 --- /dev/null +++ b/manifests/backup_remote.pp @@ -0,0 +1,67 @@ +# == Define: mysql_backup::backup_remote +# +# Arguments determine when backups should be taken, where they should +# be located, and how often they shouled be rotated. Additionally +# provide remote DB authentication details for that DB to be backed up. +# This define assumes that the mysqldump command is installed under +# /usr/bin. All reachable DBs and tables will be backed up. +# +define mysql_backup::backup_remote ( + $database_host, + $database_user, + $database_password, + $minute = '0', + $hour = '0', + $day = '*', + $dest_dir = '/var/backups/mysql_backups', + $rotation = 'daily', + $num_backups = '30' +) { + # Wrap in check as there may be mutliple backup defines backing + # up to the same dir. + if ! defined(File[$dest_dir]) { + file { $dest_dir: + ensure => directory, + mode => '0755', + owner => 'root', + group => 'root', + } + } + $defaults_file = "/root/.${name}_db.cnf" + file { $defaults_file: + ensure => present, + mode => '0400', + owner => 'root', + group => 'root', + content => template('mysql_backup/my.cnf.erb'), + } + + if ! defined(Package['mysql-client']) { + package { 'mysql-client': + ensure => present, + } + } + + cron { "${name}-backup": + ensure => present, + command => "/usr/bin/mysqldump --defaults-file=${defaults_file} --opt --ignore-table mysql.event --all-databases | gzip -9 > ${dest_dir}/${name}.sql.gz", + minute => $minute, + hour => $hour, + weekday => $day, + require => [ + File[$dest_dir], + File[$defaults_file], + ], + } + + include logrotate + logrotate::file { "${name}-rotate": + log => "${dest_dir}/${name}.sql.gz", + options => [ + 'nocompress', + "rotate ${num_backups}", + $rotation, + ], + require => Cron["${name}-backup"], + } +} diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb new file mode 100644 index 0000000..c168a7d --- /dev/null +++ b/templates/my.cnf.erb @@ -0,0 +1,4 @@ +[client] +host=<%= database_host %> +user=<%= database_user %> +password=<%= database_password %>