Various adjustments to classes to align with refactored work.

Handful of changes here, such as removing flush (so that mysql_user
can be used for root password changes) and other tweaks here.

Add time option to mysql::backup.
This commit is contained in:
Ashley Penney 2013-09-13 13:12:33 -04:00
parent 3f9297e10e
commit 4d6962e868
4 changed files with 24 additions and 110 deletions

View file

@ -81,11 +81,6 @@ Puppet::Type.type(:mysql_user).provide(:mysql) do
@property_hash[:ensure] == :present || false @property_hash[:ensure] == :present || false
end end
def flush
@property_hash.clear
mysql([defaults_file, '-NBe', 'FLUSH PRIVILEGES'].compact)
end
## ##
## MySQL user properties ## MySQL user properties
## ##

View file

@ -1,32 +1,4 @@
# Class: mysql::backup # Deprecated class
#
# This module handles ...
#
# Parameters:
# [*backupuser*] - The name of the mysql backup user.
# [*backuppassword*] - The password of the mysql backup user.
# [*backupdir*] - The target directory of the mysqldump.
# [*backupcompress*] - Boolean to compress backup with bzip2.
# [*backuprotate*] - Number of backups to keep. Default 30
# [*backupdatabases*] - Specify databases to back up as array (default all)
# [*file_per_database*] - Boolean to dump each database to its own file.
# [*delete_before_dump*] - Clean existing backups before creating new
#
# Actions:
# GRANT SELECT, RELOAD, LOCK TABLES ON *.* TO 'user'@'localhost'
# IDENTIFIED BY 'password';
#
# Requires:
# Class['mysql::config']
#
# Sample Usage:
# class { 'mysql::backup':
# backupuser => 'myuser',
# backuppassword => 'mypassword',
# backupdir => '/tmp/backups',
# backupcompress => true,
# }
#
class mysql::backup ( class mysql::backup (
$backupuser, $backupuser,
$backuppassword, $backuppassword,
@ -36,48 +8,24 @@ class mysql::backup (
$delete_before_dump = false, $delete_before_dump = false,
$backupdatabases = [], $backupdatabases = [],
$file_per_database = false, $file_per_database = false,
$ensure = 'present' $ensure = 'present',
$time = ['23', '5'],
) { ) {
mysql_user { "${backupuser}@localhost": crit("This class has been deprecated and callers should directly call
ensure => $ensure, mysql::server::backup now.")
password_hash => mysql_password($backuppassword),
provider => 'mysql',
require => Class['mysql::server::config'],
}
mysql_grant { "${backupuser}@localhost/*.*": class { 'mysql::server::backup':
ensure => present, ensure => $ensure,
user => "${backupuser}@localhost", backupuser => $backupuser,
table => '*.*', backuppassword => $backuppassword,
privileges => [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW' ], backupdir => $backupdir,
require => Mysql_user["${backupuser}@localhost"], backupcompress => $backupcompress,
} backuprotate => $backuprotate,
delete_before_dump => $delete_before_dump,
cron { 'mysql-backup': backupdatabases => $backupdatabases,
ensure => $ensure, file_per_database => $file_per_database,
command => '/usr/local/sbin/mysqlbackup.sh', time => $time,
user => 'root',
hour => 23,
minute => 5,
require => File['mysqlbackup.sh'],
}
file { 'mysqlbackup.sh':
ensure => $ensure,
path => '/usr/local/sbin/mysqlbackup.sh',
mode => '0700',
owner => 'root',
group => 'root',
content => template('mysql/mysqlbackup.sh.erb'),
}
file { 'mysqlbackupdir':
ensure => 'directory',
path => $backupdir,
mode => '0700',
owner => 'root',
group => 'root',
} }
} }

View file

@ -6,7 +6,13 @@ class mysql::client (
include '::mysql::client::install' include '::mysql::client::install'
if $bindings_enable { if $bindings_enable {
include '::mysql::bindings' class { 'mysql::bindings':
java_enable => true,
perl_enable => true,
php_enable => true,
python_enable => true,
ruby_enable => true,
}
} }
} }

View file

@ -1,39 +1,4 @@
# Define: mysql::db # See README.md for details.
#
# This module creates database instances, a user, and grants that user
# privileges to the database. It can also import SQL from a file in order to,
# for example, initialize a database schema.
#
# Since it requires class mysql::server, we assume to run all commands as the
# root mysql user against the local mysql server.
#
# Parameters:
# [*title*] - mysql database name.
# [*user*] - username to create and grant access.
# [*password*] - user's password.
# [*collate*] - database charset.
# [*charset*] - database charset.
# [*host*] - host for assigning privileges to user.
# [*grant*] - array of privileges to grant user.
# [*enforce_sql*] - whether to enforce or conditionally run sql on creation.
# [*sql*] - sql statement to run.
# [*ensure*] - specifies if a database is present or absent.
#
# Actions:
#
# Requires:
#
# class mysql::server
#
# Sample Usage:
#
# mysql::db { 'mydb':
# user => 'my_user',
# password => 'password',
# host => $::hostname,
# grant => ['all']
# }
#
define mysql::db ( define mysql::db (
$user, $user,
$password, $password,