diff --git a/.gitignore b/.gitignore index 899499c..b79a798 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Gemfile.lock /pkg/ +.project diff --git a/lib/puppet/parser/functions/mysql_password.rb b/lib/puppet/parser/functions/percona_password.rb similarity index 76% rename from lib/puppet/parser/functions/mysql_password.rb rename to lib/puppet/parser/functions/percona_password.rb index 6443d95..3177f2d 100644 --- a/lib/puppet/parser/functions/mysql_password.rb +++ b/lib/puppet/parser/functions/percona_password.rb @@ -2,7 +2,7 @@ require 'digest/sha1' module Puppet::Parser::Functions - newfunction(:mysql_password, :type => :rvalue) do |args| + newfunction(:percona_password, :type => :rvalue) do |args| '*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase end end diff --git a/lib/puppet/provider/mysql_database/mysql.rb b/lib/puppet/provider/percona_database/mysql.rb similarity index 95% rename from lib/puppet/provider/mysql_database/mysql.rb rename to lib/puppet/provider/percona_database/mysql.rb index d733565..8ae8195 100644 --- a/lib/puppet/provider/mysql_database/mysql.rb +++ b/lib/puppet/provider/percona_database/mysql.rb @@ -1,4 +1,4 @@ -Puppet::Type.type(:mysql_database).provide(:mysql) do +Puppet::Type.type(:percona_database).provide(:mysql) do desc "Use mysql as database." diff --git a/lib/puppet/provider/mysql_grant/mysql.rb b/lib/puppet/provider/percona_grant/mysql.rb similarity index 99% rename from lib/puppet/provider/mysql_grant/mysql.rb rename to lib/puppet/provider/percona_grant/mysql.rb index 53dcc71..dac99ad 100644 --- a/lib/puppet/provider/mysql_grant/mysql.rb +++ b/lib/puppet/provider/percona_grant/mysql.rb @@ -1,4 +1,4 @@ -Puppet::Type.type(:mysql_grant).provide(:mysql) do +Puppet::Type.type(:percona_grant).provide(:mysql) do desc "Uses mysql as database." diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/percona_user/mysql.rb similarity index 87% rename from lib/puppet/provider/mysql_user/mysql.rb rename to lib/puppet/provider/percona_user/mysql.rb index 17f64dc..f373da2 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/percona_user/mysql.rb @@ -1,4 +1,4 @@ -Puppet::Type.type(:mysql_user).provide(:mysql) do +Puppet::Type.type(:percona_user).provide(:mysql) do desc "Use mysql as database." @@ -43,7 +43,7 @@ def exists? end def password_hash - mysql(mysql_args("mysql", "-NBe", "select password from mysql.user where CONCAT( user, '@', host) = '%s'" % @resource.value(:name))).chomp + mysql(mysql_args("mysql", "-NBe", "select authentication_string from mysql.user where CONCAT( user, '@', host) = '%s'" % @resource.value(:name))).chomp end def password_hash=(string) diff --git a/lib/puppet/type/mysql_database.rb b/lib/puppet/type/percona_database.rb similarity index 92% rename from lib/puppet/type/mysql_database.rb rename to lib/puppet/type/percona_database.rb index 42ea001..8ad3f5b 100644 --- a/lib/puppet/type/mysql_database.rb +++ b/lib/puppet/type/percona_database.rb @@ -1,5 +1,5 @@ # This has to be a separate type to enable collecting -Puppet::Type.newtype(:mysql_database) do +Puppet::Type.newtype(:percona_database) do @doc = "Manage a database." ensurable diff --git a/lib/puppet/type/mysql_grant.rb b/lib/puppet/type/percona_grant.rb similarity index 93% rename from lib/puppet/type/mysql_grant.rb rename to lib/puppet/type/percona_grant.rb index 327a408..8fd3866 100644 --- a/lib/puppet/type/mysql_grant.rb +++ b/lib/puppet/type/percona_grant.rb @@ -1,8 +1,8 @@ -Puppet::Type.newtype(:mysql_grant) do +Puppet::Type.newtype(:percona_grant) do @doc = "Manage a database user's rights." #ensurable - autorequire :mysql_database do + autorequire :percona_database do reqs = [] matches = self[:name].match(/^([^@]+)@([^\/]+)\/(.+)$/) unless matches.nil? @@ -11,7 +11,7 @@ reqs end - autorequire :mysql_user do + autorequire :percona_user do reqs = [] matches = self[:name].match(/^([^@]+)@([^\/]+).*$/) unless matches.nil? diff --git a/lib/puppet/type/mysql_user.rb b/lib/puppet/type/percona_user.rb similarity index 95% rename from lib/puppet/type/mysql_user.rb rename to lib/puppet/type/percona_user.rb index a411cb5..805ea43 100644 --- a/lib/puppet/type/mysql_user.rb +++ b/lib/puppet/type/percona_user.rb @@ -1,4 +1,4 @@ -Puppet::Type.newtype(:mysql_user) do +Puppet::Type.newtype(:percona_user) do @doc = "Manage a database user." ensurable diff --git a/manifests/config/server.pp b/manifests/config/server.pp index b76cdff..388d454 100644 --- a/manifests/config/server.pp +++ b/manifests/config/server.pp @@ -133,11 +133,13 @@ } } - file { $logdir : - ensure => 'directory', - mode => $config_dir_mode, - owner => $daemon_user, - group => $logdir_group, + unless File["${logdir}"] { + file { $logdir : + ensure => 'directory', + mode => $config_dir_mode, + owner => $daemon_user, + group => $logdir_group, + } } if $config_skip != true { diff --git a/manifests/database.pp b/manifests/database.pp index 722fdfa..e0ef907 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -22,7 +22,7 @@ default => $mgmt_cnf, } - mysql_database { $name: + percona_database { $name: ensure => $ensure, charset => $charset, mgmt_cnf => $mycnf, diff --git a/manifests/init.pp b/manifests/init.pp index 13fd98e..8f64508 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -110,7 +110,11 @@ $template = $percona::params::template, $config_dir = $percona::params::config_dir, $config_file = $percona::params::_config_file, - + + $log_bin = $percona::params::log_bin, + $relay_log = $percona::params::relay_log, + $slow_query_log_file = $percona::params::slow_query_log_file, + ) inherits percona::params { $config_include_dir_default = $::percona::params::config_include_dir_default @@ -131,9 +135,9 @@ 'mysqld/socket' => $::percona::socket, 'mysqld/user' => $::percona::daemon_user, 'mysqld/innodb_log_group_home_dir' => $::percona::datadir, - 'mysqld/log_bin' => "${::percona::datadir}/${sanitized_servername}-bin", - 'mysqld/relay_log' => "${::percona::datadir}/${sanitized_servername}-relay", - 'mysqld/slow_query_log_file' => "${::percona::logdir}/${::percona::servername}-slow.log", + 'mysqld/log_bin' => $log_bin ? { undef => "${::percona::datadir}/${sanitized_servername}-bin", default => $log_bin }, + 'mysqld/relay_log' => $relay_log ? { undef => "${::percona::datadir}/${sanitized_servername}-relay", default => $relay_log }, + 'mysqld/slow_query_log_file' => $slow_query_log_file ? { undef => "${::percona::logdir}/${::percona::servername}-slow.log", default => $slow_query_log_file }, 'mysqld/symbolic-links' => '0', 'mysqld_safe/log-error' => $::percona::errorlog, diff --git a/manifests/install.pp b/manifests/install.pp index b74d345..ce03d86 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -47,6 +47,15 @@ default => $::percona::pkg_compat, } } + '5.6': { + $pkg_compat = $::percona::pkg_compat + } + '5.7': { + $pkg_compat = $::percona::pkg_compat ? { + undef => 'Percona-Server-shared-compat-57', + default => $::percona::pkg_compat, + } + } default: { $pkg_compat = $::percona::pkg_compat ? { undef => 'Percona-SQL-shared-compat', diff --git a/manifests/params.pp b/manifests/params.pp index 0d46a60..7733793 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -88,7 +88,11 @@ '5.5' => {}, '5.1' => {}, 'global' => {}, - } + }, + + $log_bin = undef, + $relay_log = undef, + $slow_query_log_file = undef, ) { case $::operatingsystem { diff --git a/manifests/rights.pp b/manifests/rights.pp index 0eb81f2..a311d77 100644 --- a/manifests/rights.pp +++ b/manifests/rights.pp @@ -126,13 +126,13 @@ default => "${_user}@${_host}/${_database}", } - if ! defined(Mysql_user["${_user}@${_host}"]) { + if ! defined(Percona_user["${_user}@${_host}"]) { $pwhash = $hash ? { - undef => mysql_password($password), + undef => percona_password($password), default => $hash, } - mysql_user { "${_user}@${_host}": + percona_user { "${_user}@${_host}": ensure => $ensure, password_hash => $pwhash, mgmt_cnf => $mycnf, @@ -142,12 +142,12 @@ } } - mysql_grant { $grant_name: + percona_grant { $grant_name: privileges => $priv, mgmt_cnf => $mycnf, require => [ Service[$::percona::service_name], - Mysql_user["${_user}@${_host}"], + Percona_user["${_user}@${_host}"], ] }