Changeset - cfe67ad68fc5
[Not reviewed]
0 4 0
Branko Majic (branko) - 5 years ago 2021-01-13 22:35:21
branko@majic.rs
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.
4 files changed with 32 insertions and 3 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -2098,12 +2098,13 @@ Parameters
 
Distribution compatibility
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Role is compatible with the following distributions:
 

	
 
- Debian 9 (Stretch)
 
- Debian 10 (Buster)
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for creating a single database (for some
roles/database/meta/main.yml
Show inline comments
 
@@ -15,8 +15,8 @@ galaxy_info:
 
  description: Creates MariaDB database and accompanying user to access it
 
  license: BSD
 
  min_ansible_version: 2.9
 
  platforms:
 
    - name: Debian
 
      versions:
 
        - 8
 
        - 9
 
        - 10
roles/database/molecule/default/molecule.yml
Show inline comments
 
@@ -26,12 +26,26 @@ platforms:
 
      - parameters-optional
 
      - backup-server
 
    box: debian/contrib-stretch64
 
    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
 
  config_options:
 
    defaults:
 
      force_valid_group_names: "ignore"
roles/database/molecule/default/tests/test_default.py
Show inline comments
 
@@ -31,17 +31,31 @@ def test_database_user_login(host):
 

	
 
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
 
    assert visible_databases.stdout == "information_schema\ntestdb\n"
 

	
 
    with host.sudo():
 
        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
0 comments (0 inline, 0 general)