From 95901ad795b4b218ba84fa0ba996732cba665811 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Sat, 21 Sep 2024 00:12:50 +0300 Subject: [PATCH 1/2] Use link target for mysql command --- lib/puppet/provider/mysql.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index ef750039f..f441ad1a0 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -38,7 +38,12 @@ class Puppet::Provider::Mysql < Puppet::Provider ].join(':') # rubocop:disable Style/HashSyntax - commands :mysql_raw => 'mysql' + if File.symlink?(Facter::Core::Execution.which('mysql')) + real_command = File.readlink(Facter::Core::Execution.which('mysql')) + else + real_command = Facter::Core::Execution.which('mysql') + end + commands :mysql_raw => real_command commands :mysqld => 'mysqld' commands :mysqladmin => 'mysqladmin' # rubocop:enable Style/HashSyntax From d6480e4ee6cadec1148fd1428c34f1741d07ae44 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Sat, 21 Sep 2024 00:29:37 +0300 Subject: [PATCH 2/2] Get links for other commands --- lib/puppet/provider/mysql.rb | 17 ++++++++++++----- tasks/export.rb | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index f441ad1a0..5ee43cab1 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -39,13 +39,20 @@ class Puppet::Provider::Mysql < Puppet::Provider # rubocop:disable Style/HashSyntax if File.symlink?(Facter::Core::Execution.which('mysql')) - real_command = File.readlink(Facter::Core::Execution.which('mysql')) + commands :mysql_raw => File.readlink(Facter::Core::Execution.which('mysql')) else - real_command = Facter::Core::Execution.which('mysql') + commands :mysql_raw => Facter::Core::Execution.which('mysql') + end + if File.symlink?(Facter::Core::Execution.which('mysqld')) + commands :mysqld => File.readlink(Facter::Core::Execution.which('mysqld')) + else + commands :mysqld => 'mysqld' + end + if File.symlink?(Facter::Core::Execution.which('mysqladmin')) + commands :mysqladmin => File.readlink(Facter::Core::Execution.which('mysqladmin')) + else + commands :mysqladmin => 'mysqladmin' end - commands :mysql_raw => real_command - commands :mysqld => 'mysqld' - commands :mysqladmin => 'mysqladmin' # rubocop:enable Style/HashSyntax # Optional defaults file diff --git a/tasks/export.rb b/tasks/export.rb index 7688633ae..c57000456 100755 --- a/tasks/export.rb +++ b/tasks/export.rb @@ -6,7 +6,11 @@ require 'puppet' def get(file, database, user, password) - cmd_string = 'mysqldump' + if File.symlink?(Facter::Core::Execution.which('mysqldump')) + cmd_string = File.readlink(Facter::Core::Execution.which('mysqldump')) + else + cmd_string = 'mysqldump' + end cmd_string << " --databases #{database}" unless database.nil? cmd_string << " --user=#{user}" unless user.nil? cmd_string << " --password=#{password}" unless password.nil?