Use defaults_extra_file first; add debug messages

Remove added notices and revert to debug

Add support for Percona

Use log-error for mysqld initialize

Improve description of error log argument

Should be --log-error
This commit is contained in:
Monty Solomon 2016-04-05 22:36:40 -04:00
parent 9bc20bd7cc
commit d472d5bcf1
4 changed files with 16 additions and 8 deletions

View file

@ -18,6 +18,7 @@ Puppet::Type.type(:mysql_datadir).provide(:mysql, :parent => Puppet::Provider::M
user = @resource.value(:user) || "mysql"
basedir = @resource.value(:basedir) || "/usr"
datadir = @resource.value(:datadir) || @resource[:name]
log_error = @resource.value(:log_error) || "/var/tmp/mysqld_initialize.log"
unless defaults_extra_file.nil?
if File.exist?(defaults_extra_file)
@ -34,15 +35,15 @@ Puppet::Type.type(:mysql_datadir).provide(:mysql, :parent => Puppet::Provider::M
end
if mysqld_version.nil?
debug("Installing MySQL data directory with mysql_install_db --basedir=#{basedir} #{defaults_extra_file} --datadir=#{datadir} --user=#{user}")
mysql_install_db(["--basedir=#{basedir}",defaults_extra_file, "--datadir=#{datadir}", "--user=#{user}"].compact)
debug("Installing MySQL data directory with mysql_install_db #{defaults_extra_file} --basedir=#{basedir} --datadir=#{datadir} --user=#{user}")
mysql_install_db([defaults_extra_file, "--basedir=#{basedir}", "--datadir=#{datadir}", "--user=#{user}"].compact)
else
if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
debug("Initializing MySQL data directory >= 5.7.6 with 'mysqld #{defaults_extra_file} #{initialize} --basedir=#{basedir} --datadir=#{datadir} --user=#{user}'")
mysqld([defaults_extra_file,initialize,"--basedir=#{basedir}","--datadir=#{datadir}", "--user=#{user}", "--log_error=/var/tmp/mysqld_initialize.log"].compact)
mysqld([defaults_extra_file, initialize, "--basedir=#{basedir}", "--datadir=#{datadir}", "--user=#{user}", "--log-error=#{log_error}"].compact)
else
debug("Installing MySQL data directory with mysql_install_db --basedir=#{basedir} #{defaults_extra_file} --datadir=#{datadir} --user=#{user}")
mysql_install_db(["--basedir=#{basedir}",defaults_extra_file, "--datadir=#{datadir}", "--user=#{user}"].compact)
debug("Installing MySQL data directory with mysql_install_db #{defaults_extra_file} --basedir=#{basedir} --datadir=#{datadir} --user=#{user}")
mysql_install_db([defaults_extra_file, "--basedir=#{basedir}", "--datadir=#{datadir}", "--user=#{user}"].compact)
end
end

View file

@ -16,7 +16,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysq
## Default ...
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
else
if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
else
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
@ -109,7 +109,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysq
mysql([defaults_file, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact)
else
# Version >= 5.7.6 (many password related changes)
if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0
if string.match(/^\*/)
mysql([defaults_file, '-e', "ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'"].compact)
else

View file

@ -27,4 +27,9 @@ Puppet::Type.newtype(:mysql_datadir) do
desc "Insecure initialization (needed for 5.7.6++)."
end
newparam(:log_error) do
desc "The path to the mysqld error log file (used with the --log-error option)"
newvalues(/^\//)
end
end

View file

@ -8,6 +8,7 @@ class mysql::server::installdb {
$datadir = $mysql::server::options['mysqld']['datadir']
$basedir = $mysql::server::options['mysqld']['basedir']
$config_file = $mysql::server::config_file
$log_error = $mysql::server::options['mysqld']['log-error']
if $mysql::server::manage_config_file and $config_file != $mysql::params::config_file {
$_config_file=$config_file
@ -20,6 +21,7 @@ class mysql::server::installdb {
datadir => $datadir,
basedir => $basedir,
user => $mysqluser,
log_error => $log_error,
defaults_extra_file => $_config_file,
}