Skip to content

Commit

Permalink
add utils function to get server type (MySQL vs MariaDB)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-indermuehle committed Oct 11, 2023
1 parent a7ea113 commit 3da5b34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/module_utils/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ def mysql_common_argument_spec():
)


def get_server_type(cursor):
""" Return MySQL or MariaDB after quering the server
using SELECT VERSION()"""
srv_ver = get_server_version(cursor)
return 'mariadb' if 'mariadb' in srv_ver.lower() else "mysql"


def get_server_version(cursor):
"""Returns a string representation of the server version."""
cursor.execute("SELECT VERSION() AS version")
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from ansible_collections.community.mysql.plugins.module_utils.mysql import (
mysql_driver,
get_server_type,
)


Expand Down

0 comments on commit 3da5b34

Please sign in to comment.