Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/puppet/provider/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for the my.puppet.cnf filename? is that something that should be configureable / why can't you use the .mylogin.cnf? do you create the .my.puppet.cnf via puppet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no this cant be configurable, because it is used in a type, which is before hiera. I really which it would be possible to configure.
The .mylogin.cnf is only available on mysql, and not mariadb.

If you want, another possibility could be to not use a different file, but the --login-path command line option. I would need to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

answering all questions: the filename is just chosen by looking at the stars, correlating it with average windspeed during my dogwalk. I personally create the file using puppet, most would. Should i hack this into the module to do it for us? There is a chance that users of this file would want to add mysterious and unforseen options to it.

end

def self.mysqld_type
# find the mysql "dialect" like mariadb / mysql etc.
mysqld_version_string.scan(%r{mariadb}i) { return 'mariadb' }
Expand Down Expand Up @@ -101,18 +106,26 @@ 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
elsif type.eql? 'regular'
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
Expand Down