Skip to content

Commit b3ff102

Browse files
committed
MySQL 8.0: Grant required privileges to xtrabackup user
1 parent 506563b commit b3ff102

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

manifests/backup/xtrabackup.pp

+16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@
6767
require => Mysql_user["${backupuser}@localhost"],
6868
}
6969
}
70+
if versioncmp($facts['mysql_version'], '8') >= 0 {
71+
mysql_grant { "${backupuser}@localhost/performance_schema.keyring_component_status":
72+
ensure => $ensure,
73+
user => "${backupuser}@localhost",
74+
table => 'performance_schema.keyring_component_status',
75+
privileges => ['SELECT'],
76+
require => Mysql_user["${backupuser}@localhost"],
77+
}
78+
mysql_grant { "${backupuser}@localhost/performance_schema.log_status":
79+
ensure => $ensure,
80+
user => "${backupuser}@localhost",
81+
table => 'performance_schema.log_status',
82+
privileges => ['SELECT'],
83+
require => Mysql_user["${backupuser}@localhost"],
84+
}
85+
}
7086
}
7187

7288
if $install_cron {

spec/classes/mysql_backup_xtrabackup_spec.rb

+41-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class { 'mysql::server': }
1111
EOF
1212
end
1313
let(:facts) do
14-
facts.merge(root_home: '/root')
14+
facts.merge(root_home: '/root',
15+
mysql_version: '5.7')
1516
end
1617

1718
let(:default_params) do
@@ -114,6 +115,45 @@ class { 'mysql::server': }
114115
)
115116
.that_requires('Mysql_user[backupuser@localhost]')
116117
end
118+
119+
context 'with MySQL version 5.7' do
120+
let(:facts) do
121+
facts.merge(mysql_version: '5.7')
122+
end
123+
124+
it {
125+
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
126+
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
127+
}
128+
end
129+
130+
context 'with MySQL version 8.0' do
131+
let(:facts) do
132+
facts.merge(mysql_version: '8.0')
133+
end
134+
135+
it {
136+
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
137+
.with(
138+
ensure: 'present',
139+
user: 'backupuser@localhost',
140+
table: 'performance_schema.keyring_component_status',
141+
privileges:
142+
['SELECT']
143+
)
144+
.that_requires('Mysql_user[backupuser@localhost]')
145+
146+
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
147+
.with(
148+
ensure: 'present',
149+
user: 'backupuser@localhost',
150+
table: 'performance_schema.log_status',
151+
privileges:
152+
['SELECT']
153+
)
154+
.that_requires('Mysql_user[backupuser@localhost]')
155+
}
156+
end
117157
end
118158

119159
context 'with additional cron args' do

0 commit comments

Comments
 (0)