parent
ea1bd0b078
commit
a65965e38e
1 changed files with 32 additions and 0 deletions
|
@ -42,6 +42,8 @@ options:
|
|||
- changemaster
|
||||
- stopslave
|
||||
- startslave
|
||||
- resetslave
|
||||
- resetslaveall
|
||||
default: getslave
|
||||
login_user:
|
||||
description:
|
||||
|
@ -165,6 +167,24 @@ def stop_slave(cursor):
|
|||
return stopped
|
||||
|
||||
|
||||
def reset_slave(cursor):
|
||||
try:
|
||||
cursor.execute("RESET SLAVE")
|
||||
reset = True
|
||||
except:
|
||||
reset = False
|
||||
return reset
|
||||
|
||||
|
||||
def reset_slave_all(cursor):
|
||||
try:
|
||||
cursor.execute("RESET SLAVE ALL")
|
||||
reset = True
|
||||
except:
|
||||
reset = False
|
||||
return reset
|
||||
|
||||
|
||||
def start_slave(cursor):
|
||||
try:
|
||||
cursor.execute("START SLAVE")
|
||||
|
@ -400,6 +420,18 @@ def main():
|
|||
module.exit_json(msg="Slave stopped", changed=True)
|
||||
else:
|
||||
module.exit_json(msg="Slave already stopped", changed=False)
|
||||
elif mode in "resetslave":
|
||||
reset = reset_slave(cursor)
|
||||
if reset is True:
|
||||
module.exit_json(msg="Slave reset", changed=True)
|
||||
else:
|
||||
module.exit_json(msg="Slave already reset", changed=False)
|
||||
elif mode in "resetslaveall":
|
||||
reset = reset_slave_all(cursor)
|
||||
if reset is True:
|
||||
module.exit_json(msg="Slave reset", changed=True)
|
||||
else:
|
||||
module.exit_json(msg="Slave already reset", changed=False)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
|
Loading…
Reference in a new issue