Add mysql.get_version_string() convenience function

This commit is contained in:
Lance Edgar 2023-08-04 16:32:42 -05:00
parent ab1baaa6d2
commit e2369b1f53

View file

@ -24,6 +24,8 @@
Fabric Library for MySQL
"""
import re
from rattail_fabric2 import apt, make_deploy, sed
@ -38,6 +40,18 @@ def install(c):
apt.install(c, 'default-mysql-server')
def get_version_string(c):
"""
Fetch the version of MySQL running on the target system
"""
result = c.sudo('mysql --version', warn=True)
if not result.failed:
# match = re.match(r'^mysql .*?(\d+\.\d+\.\d+)-MariaDB', result.stdout)
match = re.match(r'^mysql +Ver +(\d+\.\d+\.\d+)-.*', result.stdout)
if match:
return match.group(1)
def set_bind_address(c, address):
"""
Configure the 'bind-address' setting with the given value.