diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index 2c572bb51..8f3faca42 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -48,6 +48,11 @@ def self.defaults_file "--defaults-extra-file=#{Facter.value(:root_home)}/.my.cnf" if File.file?("#{Facter.value(:root_home)}/.my.cnf") end + # Optional puppet-defaults file + def self.puppet_defaults_file + "--defaults-file=#{Facter.value(:root_home)}/.my.puppet.cnf" if File.file?("#{Facter.value(:root_home)}/.my.puppet.cnf") + end + def self.mysqld_type # find the mysql "dialect" like mariadb / mysql etc. mysqld_version_string.scan(%r{mariadb}i) { return 'mariadb' } @@ -101,11 +106,17 @@ def defaults_file self.class.defaults_file end + def puppet_defaults_file + self.class.puppet_defaults_file + end + def self.mysql_caller(text_of_sql, type) if type.eql? 'system' if File.file?("#{Facter.value(:root_home)}/.mylogin.cnf") ENV['MYSQL_TEST_LOGIN_FILE'] = "#{Facter.value(:root_home)}/.mylogin.cnf" mysql_raw([system_database, '-e', text_of_sql].flatten.compact).scrub + elsif File.file?("#{Facter.value(:root_home)}/.my.puppet.cnf") + mysql_raw([puppet_defaults_file, system_database, '-e', text_of_sql].flatten.compact).scrub else mysql_raw([defaults_file, system_database, '-e', text_of_sql].flatten.compact).scrub end @@ -113,6 +124,8 @@ def self.mysql_caller(text_of_sql, type) if File.file?("#{Facter.value(:root_home)}/.mylogin.cnf") ENV['MYSQL_TEST_LOGIN_FILE'] = "#{Facter.value(:root_home)}/.mylogin.cnf" mysql_raw(['-NBe', text_of_sql].flatten.compact).scrub + elsif File.file?("#{Facter.value(:root_home)}/.my.puppet.cnf") + mysql_raw([puppet_defaults_file, '-NBe', text_of_sql].flatten.compact).scrub else mysql_raw([defaults_file, '-NBe', text_of_sql].flatten.compact).scrub end