Skip to content
Permalink
Browse files

Add support for the RESET MASTER command

  • Loading branch information...
tersmitten committed May 17, 2019
1 parent 27aca73 commit 99a543ba52596397cc8cc0af96a7fc856ba3784c
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/ansible/modules/database/mysql/mysql_replication.py
@@ -27,7 +27,7 @@
mode:
description:
- module operating mode. Could be getslave (SHOW SLAVE STATUS), getmaster (SHOW MASTER STATUS), changemaster (CHANGE MASTER TO), startslave
(START SLAVE), stopslave (STOP SLAVE), resetslave (RESET SLAVE), resetslaveall (RESET SLAVE ALL)
(START SLAVE), stopslave (STOP SLAVE), resetslave (RESET SLAVE), resetmaster (RESET MASTER), resetslaveall (RESET SLAVE ALL)
type: str
choices:
- getslave
@@ -36,6 +36,7 @@
- stopslave
- startslave
- resetslave
- resetmaster
- resetslaveall
default: getslave
master_host:
@@ -168,6 +169,15 @@ def reset_slave(cursor):
return reset


def reset_master(cursor):
try:
cursor.execute("RESET MASTER")
reset = True
except Exception:
reset = False
return reset


def reset_slave_all(cursor):
try:
cursor.execute("RESET SLAVE ALL")
@@ -358,6 +368,12 @@ def main():
module.exit_json(msg="Slave reset", changed=True)
else:
module.exit_json(msg="Slave already reset", changed=False)
elif mode in "resetmaster":
reset = reset_master(cursor)
if reset is True:
module.exit_json(msg="Master reset", changed=True)
else:
module.exit_json(msg="Master already reset", changed=False)
elif mode in "resetslaveall":
reset = reset_slave_all(cursor)
if reset is True:

0 comments on commit 99a543b

Please sign in to comment.
You can’t perform that action at this time.