From 96c97382bc9adf4376f0b4d8cc1ecde5f1fcc83f Mon Sep 17 00:00:00 2001 From: Arjen Heidinga Date: Wed, 27 Oct 2021 13:53:28 +0200 Subject: [PATCH 1/2] Allow for a puppet-specific configfile In some very special (read: stupid) configuration I need to supply a special configuration file so that puppet can log in. --- lib/puppet/provider/mysql.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index 2c572bb51..2cb1a6f75 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -48,6 +48,12 @@ 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 +107,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 +125,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 From 060977ca62aad44d5b201ad7345d4427d0b1e27e Mon Sep 17 00:00:00 2001 From: Arjen Heidinga Date: Fri, 29 Oct 2021 09:03:40 +0200 Subject: [PATCH 2/2] fix robocup warning --- lib/puppet/provider/mysql.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index 2cb1a6f75..8f3faca42 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -53,7 +53,6 @@ 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' }