From cfe67ad68fc5558bc88f6718256ead9a94ec1273 2021-01-13 22:35:21 From: Branko Majic Date: 2021-01-13 22:35:21 Subject: [PATCH] MAR-151: Added support for Debian 10 Buster to database role: - Updated role reference documentaiton. - Updated role meta information. - Updated tests. - Fix test that produces different outputs during invocation on Stretch/Buster. --- diff --git a/docs/rolereference.rst b/docs/rolereference.rst index 73b63f500c4e1bee51fef7466080603bda6c51c1..9249213532a4ee273d92b36a382480874f822809 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -2101,6 +2101,7 @@ Distribution compatibility Role is compatible with the following distributions: - Debian 9 (Stretch) +- Debian 10 (Buster) Examples diff --git a/roles/database/meta/main.yml b/roles/database/meta/main.yml index 69ea4fbe85922a84db6e15d70799cbd09252bd5e..9cac206d7432f6dbb638068650b6eb40e491b53f 100644 --- a/roles/database/meta/main.yml +++ b/roles/database/meta/main.yml @@ -18,5 +18,5 @@ galaxy_info: platforms: - name: Debian versions: - - 8 - 9 + - 10 diff --git a/roles/database/molecule/default/molecule.yml b/roles/database/molecule/default/molecule.yml index a6e0f9bfafa00aa778df2e3d60e420d46c8a44fb..0ba3d04667c110d4a7f0a660b7eba13128ff5acd 100644 --- a/roles/database/molecule/default/molecule.yml +++ b/roles/database/molecule/default/molecule.yml @@ -29,6 +29,20 @@ platforms: memory: 512 cpus: 1 + - name: parameters-mandatory-buster64 + groups: + - parameters-mandatory + box: debian/contrib-buster64 + memory: 256 + cpus: 1 + + - name: parameters-optional-buster64 + groups: + - parameters-optional + - backup-server + box: debian/contrib-buster64 + memory: 512 + cpus: 1 provisioner: name: ansible diff --git a/roles/database/molecule/default/tests/test_default.py b/roles/database/molecule/default/tests/test_default.py index 2150f3e0dc270a5dbe187461718ac4504694a8a7..e3c262a0f88ffe34bf6f1c139fb818974b8588f2 100644 --- a/roles/database/molecule/default/tests/test_default.py +++ b/roles/database/molecule/default/tests/test_default.py @@ -34,6 +34,20 @@ def test_database_user_permissions(host): Tests if database user has been granted correct permissions on the database. """ + ansible_facts = host.ansible("setup")["ansible_facts"] + ansible_distribution_release = ansible_facts['ansible_distribution_release'] + + # Small difference in usage of backtick (`) instead of single + # quote (') when displaying grants for user. + if ansible_distribution_release == "stretch": + expected_usage = "GRANT USAGE ON *.* TO 'testdb'@'localhost' IDENTIFIED BY PASSWORD '*676852B7FAE972722AD20D6E74781D6B1A100544'" + expected_privileges = "GRANT ALL PRIVILEGES ON `testdb`.* TO 'testdb'@'localhost'" + elif ansible_distribution_release == "buster": + expected_usage = "GRANT USAGE ON *.* TO `testdb`@`localhost` IDENTIFIED BY PASSWORD '*676852B7FAE972722AD20D6E74781D6B1A100544'" + expected_privileges = "GRANT ALL PRIVILEGES ON `testdb`.* TO `testdb`@`localhost`" + else: + raise Exception("Tried running test on unsupported distribution: %s" % ansible_distribution_release) + visible_databases = host.run("mysql -utestdb -ptestdbpassword -BNe 'show databases'") assert visible_databases.rc == 0 @@ -43,5 +57,5 @@ def test_database_user_permissions(host): permissions_command = host.run("mysql -BNe 'show grants for testdb@localhost'") permissions = permissions_command.stdout.rstrip().split("\n") assert len(permissions) == 2 - assert "GRANT USAGE ON *.* TO 'testdb'@'localhost' IDENTIFIED BY PASSWORD '*676852B7FAE972722AD20D6E74781D6B1A100544'" in permissions - assert "GRANT ALL PRIVILEGES ON `testdb`.* TO 'testdb'@'localhost'" in permissions + assert expected_usage in permissions + assert expected_privileges in permissions