Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for show binary log status statement #638

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/fragments/get_primary_show_binary_log_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:

- mysql_replication - Adds support for `SHOW BINARY LOG STATUS` and `SHOW BINLOG STATUS` on getprimary mode.
19 changes: 15 additions & 4 deletions plugins/modules/mysql_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,11 @@
import os
import warnings

from ansible_collections.community.mysql.plugins.module_utils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.mysql.plugins.module_utils.mysql import (
get_server_version,
get_server_implementation,
mysql_connect,
mysql_driver,
mysql_driver_fail_msg,
Expand All @@ -310,10 +313,18 @@


def get_primary_status(cursor):
# TODO: when it's available to change on MySQL's side,
# change MASTER to PRIMARY using the approach from
# get_replica_status() function. Same for other functions.
cursor.execute("SHOW MASTER STATUS")
term = "MASTER"

version = get_server_version(cursor)
server_implementation = get_server_implementation(cursor)
if server_implementation == "mysql" and LooseVersion(version) >= LooseVersion("8.2.0"):
term = "BINARY LOG"

if server_implementation == "mariadb" and LooseVersion(version) >= LooseVersion("10.5.2"):
term = "BINLOG"

cursor.execute("SHOW %s STATUS" % term)

primarystatus = cursor.fetchone()
return primarystatus

Expand Down
Loading