Skip to content

Commit

Permalink
(puppetlabs#1580) Add support for MariaDB 11.x
Browse files Browse the repository at this point in the history
From MariaDB 11.x, mysql* names are deprecated
(cf. https://jira.mariadb.org/browse/MDEV-29582).

Use mariadb* names instead, to set factors accordingly.
Use these factors to return the proper client binary.

Co-authored-by: Sylvain Luce <[email protected]>
Co-authored-by: Nicolas Le Gaillart <[email protected]>
  • Loading branch information
3 people committed Aug 27, 2024
1 parent 2963e39 commit 101a7ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/facter/mysql_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
mysql_ver.match(%r{\d+\.\d+\.\d+})[0] if mysql_ver
end
end

Facter.add('mysql_version') do
confine { Facter::Core::Execution.which('mariadb') }
setcode do
mysql_ver = Facter::Core::Execution.execute('mariadb --version')
mysql_ver.match(%r{\d+\.\d+\.\d+})[0] if mysql_ver
end
end
7 changes: 7 additions & 0 deletions lib/facter/mysqld_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
Facter::Core::Execution.execute('env PATH=$PATH:/usr/libexec mysqld --no-defaults -V 2>/dev/null')
end
end

Facter.add('mysqld_version') do
confine { Facter::Core::Execution.which('mariadbd') }
setcode do
Facter::Core::Execution.execute('mariadbd --no-defaults -V 2>/dev/null')
end
end
14 changes: 10 additions & 4 deletions lib/puppet/provider/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@ class Puppet::Provider::Mysql < Puppet::Provider
# rubocop:enable Style/HashSyntax

def self.mysql_raw(*args)
mysqld_version_string.scan(%r{mariadb}i) { return mariadb_client(*args) }
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
return mariadb_client(*args)
end
mysql_client(*args)
end

def self.mysqld(*args)
mysqld_version_string.scan(%r{mariadb}i) { return mariadbd_service(*args) }
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
return mariadb_client(*args)
end
mysqld_service(*args)
end

def self.mysqladmin(*args)
mysqld_version_string.scan(%r{mariadb}i) { return mariadb_admin(*args) }
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
return mariadb_client(*args)
end
mysql_admin(*args)
end

Expand All @@ -81,7 +87,7 @@ def self.mysqld_version_string
# As the possibility of the mysqld being remote we need to allow the version string to be overridden,
# this can be done by facter.value as seen below. In the case that it has not been set and the facter
# value is nil we use the mysql -v command to ensure we report the correct version of mysql for later use cases.
@mysqld_version_string ||= Facter.value(:mysqld_version) || mysqld('-V')
@mysqld_version_string ||= Facter.value(:mysqld_version) || ""
end

def mysqld_version_string
Expand Down

0 comments on commit 101a7ab

Please sign in to comment.