Skip to content

Commit 101a7ab

Browse files
Marc-DRIsyl20-drinlegaillart-dri
committed
(puppetlabs#1580) Add support for MariaDB 11.x
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]>
1 parent 2963e39 commit 101a7ab

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

lib/facter/mysql_version.rb

+8
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@
77
mysql_ver.match(%r{\d+\.\d+\.\d+})[0] if mysql_ver
88
end
99
end
10+
11+
Facter.add('mysql_version') do
12+
confine { Facter::Core::Execution.which('mariadb') }
13+
setcode do
14+
mysql_ver = Facter::Core::Execution.execute('mariadb --version')
15+
mysql_ver.match(%r{\d+\.\d+\.\d+})[0] if mysql_ver
16+
end
17+
end

lib/facter/mysqld_version.rb

+7
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77
Facter::Core::Execution.execute('env PATH=$PATH:/usr/libexec mysqld --no-defaults -V 2>/dev/null')
88
end
99
end
10+
11+
Facter.add('mysqld_version') do
12+
confine { Facter::Core::Execution.which('mariadbd') }
13+
setcode do
14+
Facter::Core::Execution.execute('mariadbd --no-defaults -V 2>/dev/null')
15+
end
16+
end

lib/puppet/provider/mysql.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,23 @@ class Puppet::Provider::Mysql < Puppet::Provider
4747
# rubocop:enable Style/HashSyntax
4848

4949
def self.mysql_raw(*args)
50-
mysqld_version_string.scan(%r{mariadb}i) { return mariadb_client(*args) }
50+
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
51+
return mariadb_client(*args)
52+
end
5153
mysql_client(*args)
5254
end
5355

5456
def self.mysqld(*args)
55-
mysqld_version_string.scan(%r{mariadb}i) { return mariadbd_service(*args) }
57+
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
58+
return mariadb_client(*args)
59+
end
5660
mysqld_service(*args)
5761
end
5862

5963
def self.mysqladmin(*args)
60-
mysqld_version_string.scan(%r{mariadb}i) { return mariadb_admin(*args) }
64+
if self.newer_than('mariadb' => '11.0.0') and mysqld_version_string.scan(%r{mariadb}i)
65+
return mariadb_client(*args)
66+
end
6167
mysql_admin(*args)
6268
end
6369

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

8793
def mysqld_version_string

0 commit comments

Comments
 (0)