@@ -266,7 +266,46 @@ class { 'mysql::server':
266266 end
267267 end
268268
269+ # On Ubuntu 20.04 'ALL' now returns as the sum of it's constitute parts and so require a specific test
270+ describe 'ALL privilege on newer MySQL versions' , if : os [ :family ] == 'ubuntu' && os [ :release ] =~ %r{^20\. 04} do
271+ pp_one = <<-MANIFEST
272+ mysql_user { 'all@localhost':
273+ ensure => present,
274+ }
275+ mysql_grant { 'all@localhost/*.*':
276+ user => 'all@localhost',
277+ privileges => ['ALL'],
278+ table => '*.*',
279+ require => Mysql_user['all@localhost'],
280+ }
281+ MANIFEST
282+ it "create ['ALL'] privs" do
283+ apply_manifest ( pp_one , catch_failures : true )
284+ end
285+
286+ pp_two = <<-MANIFEST
287+ mysql_user { 'all@localhost':
288+ ensure => present,
289+ }
290+ mysql_grant { 'all@localhost/*.*':
291+ user => 'all@localhost',
292+ privileges => ['ALTER', 'ALTER ROUTINE', 'CREATE', 'CREATE ROLE', 'CREATE ROUTINE', 'CREATE TABLESPACE', 'CREATE TEMPORARY TABLES', 'CREATE USER', 'CREATE VIEW', 'DELETE', 'DROP', 'DROP ROLE', 'EVENT', 'EXECUTE', 'FILE', 'INDEX', 'INSERT', 'LOCK TABLES', 'PROCESS', 'REFERENCES', 'RELOAD', 'REPLICATION CLIENT', 'REPLICATION SLAVE', 'SELECT', 'SHOW DATABASES', 'SHOW VIEW', 'SHUTDOWN', 'SUPER', 'TRIGGER', 'UPDATE'],
293+ table => '*.*',
294+ require => Mysql_user['all@localhost'],
295+ }
296+ MANIFEST
297+ it "create ['ALL'] constitute parts privs" do
298+ apply_manifest ( pp_two , catch_changes : true )
299+ end
300+ end
301+
269302 describe 'complex test' do
303+ # On Ubuntu 20.04 'ALL' now returns as the sum of it's constitute parts and so is no longer idempotent when set
304+ privileges = if os [ :family ] == 'ubuntu' && os [ :release ] =~ %r{^20\. 04}
305+ "['SELECT', 'INSERT', 'UPDATE']"
306+ else
307+ "['ALL']"
308+ end
270309 pp = <<-MANIFEST
271310 $dbSubnet = '10.10.10.%'
272311
@@ -284,7 +323,7 @@ class { 'mysql::server':
284323 Mysql_grant {
285324 ensure => present,
286325 options => ['GRANT'],
287- privileges => ['ALL'] ,
326+ privileges => #{ privileges } ,
288327 table => '*.*',
289328 require => [ Mysql_database['foo'], Exec['mysql-create-table'] ],
290329 }
@@ -355,12 +394,12 @@ class { 'mysql::server':
355394 }
356395 mysql_grant { 'lowercase@localhost/*.*':
357396 user => 'lowercase@localhost',
358- privileges => 'ALL' ,
397+ privileges => ['SELECT', 'INSERT', 'UPDATE'] ,
359398 table => '*.*',
360399 require => Mysql_user['lowercase@localhost'],
361400 }
362401 MANIFEST
363- it ' create ALL privs' do
402+ it " create ['SELECT', 'INSERT', 'UPDATE'] privs" do
364403 apply_manifest ( pp_one , catch_failures : true )
365404 end
366405
@@ -370,12 +409,12 @@ class { 'mysql::server':
370409 }
371410 mysql_grant { 'lowercase@localhost/*.*':
372411 user => 'lowercase@localhost',
373- privileges => 'all' ,
412+ privileges => ['select', 'insert', 'update'] ,
374413 table => '*.*',
375414 require => Mysql_user['lowercase@localhost'],
376415 }
377416 MANIFEST
378- it ' create lowercase all privs' do
417+ it " create lowercase ['select', 'insert', 'update'] privs" do
379418 apply_manifest ( pp_two , catch_changes : true )
380419 end
381420 end
0 commit comments