Skip to content

Commit 815a2a6

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

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-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

+33-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
@@ -113,6 +114,37 @@ class { 'mysql::server': }
113114
end,
114115
)
115116
.that_requires('Mysql_user[backupuser@localhost]')
117+
118+
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
119+
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
120+
end
121+
122+
context 'with MySQL version 8.0' do
123+
let(:facts) do
124+
facts.merge(mysql_version: '8.0')
125+
end
126+
127+
it {
128+
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
129+
.with(
130+
ensure: 'present',
131+
user: 'backupuser@localhost',
132+
table: 'performance_schema.keyring_component_status',
133+
privileges:
134+
['SELECT']
135+
)
136+
.that_requires('Mysql_user[backupuser@localhost]')
137+
138+
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
139+
.with(
140+
ensure: 'present',
141+
user: 'backupuser@localhost',
142+
table: 'performance_schema.log_status',
143+
privileges:
144+
['SELECT']
145+
)
146+
.that_requires('Mysql_user[backupuser@localhost]')
147+
}
116148
end
117149
end
118150

0 commit comments

Comments
 (0)