From d0ec09d5bef98f7196cb3ddfa18a743769b3ec51 Mon Sep 17 00:00:00 2001 From: Nemanja Delic Date: Tue, 29 Aug 2023 19:24:13 +0000 Subject: [PATCH 1/3] Ensure fact mysql_version exist when granting privileges to xtrabackup user in MySQL 8.0 --- manifests/backup/xtrabackup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index c73831f38..ede685966 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -50,7 +50,7 @@ require => Class['mysql::server::root_password'], } # Percona XtraBackup needs additional grants/privileges to work with MySQL 8 - if versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) { + if (defined('$facts["mysql_version"]')) and versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) { if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') >= 0) or ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) { mysql_grant { "${backupuser}@localhost/*.*": From b16c9b95604b0fbad4e84ac01fc07e6d7bad6673 Mon Sep 17 00:00:00 2001 From: Nemanja Delic Date: Tue, 29 Aug 2023 20:07:04 +0000 Subject: [PATCH 2/3] trying to fix spec test --- manifests/backup/xtrabackup.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index ede685966..228bdec7a 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -43,14 +43,14 @@ $backuppassword } - if $backupuser and $backuppassword { + if (defined('$facts["mysql_version"]')) and $backupuser and $backuppassword { mysql_user { "${backupuser}@localhost": ensure => $ensure, password_hash => Deferred('mysql::password', [$backuppassword]), require => Class['mysql::server::root_password'], } # Percona XtraBackup needs additional grants/privileges to work with MySQL 8 - if (defined('$facts["mysql_version"]')) and versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) { + if versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) { if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') >= 0) or ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) { mysql_grant { "${backupuser}@localhost/*.*": From 3a3c69eeeff2ae52e0e74c48cd44570317101701 Mon Sep 17 00:00:00 2001 From: Nemanja Delic Date: Thu, 31 Aug 2023 12:30:15 +0000 Subject: [PATCH 3/3] trying to fix first run using explicit param is_mysql_v8 --- manifests/backup/xtrabackup.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index 228bdec7a..e6968cefc 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -33,7 +33,8 @@ Optional[String[1]] $compression_command = undef, Optional[String[1]] $compression_extension = undef, String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name, - Array[String] $excludedatabases = [], + Array[String] $excludedatabases = [], + Boolean $is_mysql_v8 = false, ) inherits mysql::params { stdlib::ensure_packages($backupmethod_package) @@ -43,14 +44,14 @@ $backuppassword } - if (defined('$facts["mysql_version"]')) and $backupuser and $backuppassword { + if $backupuser and $backuppassword { mysql_user { "${backupuser}@localhost": ensure => $ensure, password_hash => Deferred('mysql::password', [$backuppassword]), require => Class['mysql::server::root_password'], } # Percona XtraBackup needs additional grants/privileges to work with MySQL 8 - if versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) { + if ($is_mysql_v8 or versioncmp($facts['mysql_version'], '8') >= 0) and !(/(?i:mariadb)/ in $facts['mysqld_version']) { if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') >= 0) or ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) { mysql_grant { "${backupuser}@localhost/*.*":