|
|
@ -2,6 +2,7 @@
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# Copyright: (c) 2013, Balazs Pocze <banyek@gawker.com>
|
|
|
|
# Copyright: (c) 2013, Balazs Pocze <banyek@gawker.com>
|
|
|
|
|
|
|
|
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
|
|
|
# Certain parts are taken from Mark Theunissen's mysqldb module
|
|
|
|
# Certain parts are taken from Mark Theunissen's mysqldb module
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
|
@ -19,124 +20,142 @@ DOCUMENTATION = r'''
|
|
|
|
module: mysql_replication
|
|
|
|
module: mysql_replication
|
|
|
|
short_description: Manage MySQL replication
|
|
|
|
short_description: Manage MySQL replication
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Manages MySQL server replication, slave, master status get and change master host.
|
|
|
|
- Manages MySQL server replication, slave, master status, get and change master host.
|
|
|
|
version_added: "1.3"
|
|
|
|
version_added: '1.3'
|
|
|
|
author:
|
|
|
|
author:
|
|
|
|
- Balazs Pocze (@banyek)
|
|
|
|
- Balazs Pocze (@banyek)
|
|
|
|
|
|
|
|
- Andrew Klychkov (@Andersson007)
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
mode:
|
|
|
|
mode:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- module operating mode. Could be getslave (SHOW SLAVE STATUS), getmaster (SHOW MASTER STATUS), changemaster (CHANGE MASTER TO), startslave
|
|
|
|
- Module operating mode. Could be
|
|
|
|
(START SLAVE), stopslave (STOP SLAVE), resetslave (RESET SLAVE), resetslaveall (RESET SLAVE ALL)
|
|
|
|
C(changemaster) (CHANGE MASTER TO),
|
|
|
|
type: str
|
|
|
|
C(getmaster) (SHOW MASTER STATUS),
|
|
|
|
choices:
|
|
|
|
C(getslave) (SHOW SLAVE STATUS),
|
|
|
|
- getslave
|
|
|
|
C(startslave) (START SLAVE),
|
|
|
|
- getmaster
|
|
|
|
C(stopslave) (STOP SLAVE),
|
|
|
|
- changemaster
|
|
|
|
C(resetslave) (RESET SLAVE),
|
|
|
|
- stopslave
|
|
|
|
C(resetslaveall) (RESET SLAVE ALL).
|
|
|
|
- startslave
|
|
|
|
type: str
|
|
|
|
- resetslave
|
|
|
|
choices:
|
|
|
|
- resetslaveall
|
|
|
|
- changemaster
|
|
|
|
default: getslave
|
|
|
|
- getmaster
|
|
|
|
master_host:
|
|
|
|
- getslave
|
|
|
|
description:
|
|
|
|
- startslave
|
|
|
|
- Same as mysql variable.
|
|
|
|
- stopslave
|
|
|
|
type: str
|
|
|
|
- resetslave
|
|
|
|
master_user:
|
|
|
|
- resetslaveall
|
|
|
|
description:
|
|
|
|
default: getslave
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_host:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_password:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_user:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_port:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_password:
|
|
|
|
type: int
|
|
|
|
description:
|
|
|
|
master_connect_retry:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_port:
|
|
|
|
type: int
|
|
|
|
description:
|
|
|
|
master_log_file:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: int
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_connect_retry:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_log_pos:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: int
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_log_file:
|
|
|
|
type: int
|
|
|
|
description:
|
|
|
|
relay_log_file:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_log_pos:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
relay_log_pos:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: int
|
|
|
|
- Same as mysql variable.
|
|
|
|
relay_log_file:
|
|
|
|
type: int
|
|
|
|
description:
|
|
|
|
master_ssl:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
relay_log_pos:
|
|
|
|
type: bool
|
|
|
|
description:
|
|
|
|
master_ssl_ca:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: int
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_ssl:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_ssl_capath:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: bool
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_ssl_ca:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_ssl_cert:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_ssl_capath:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_ssl_key:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_ssl_cert:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_ssl_cipher:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_ssl_key:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_auto_position:
|
|
|
|
- Same as mysql variable.
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Whether the host uses GTID based replication or not.
|
|
|
|
master_ssl_cipher:
|
|
|
|
type: bool
|
|
|
|
description:
|
|
|
|
version_added: "2.0"
|
|
|
|
- Same as mysql variable.
|
|
|
|
master_use_gtid:
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
master_auto_position:
|
|
|
|
- Configures the slave to use the MariaDB Global Transaction ID.
|
|
|
|
description:
|
|
|
|
- C(disabled) equals MASTER_USE_GTID=no command.
|
|
|
|
- Whether the host uses GTID based replication or not.
|
|
|
|
- To find information about available values see
|
|
|
|
type: bool
|
|
|
|
U(https://mariadb.com/kb/en/library/change-master-to/#master_use_gtid).
|
|
|
|
version_added: '2.0'
|
|
|
|
- Available since MariaDB 10.0.2.
|
|
|
|
master_use_gtid:
|
|
|
|
choices: [current_pos, slave_pos, disabled]
|
|
|
|
description:
|
|
|
|
type: str
|
|
|
|
- Configures the slave to use the MariaDB Global Transaction ID.
|
|
|
|
version_added: "2.10"
|
|
|
|
- C(disabled) equals MASTER_USE_GTID=no command.
|
|
|
|
master_delay:
|
|
|
|
- To find information about available values see
|
|
|
|
description:
|
|
|
|
U(https://mariadb.com/kb/en/library/change-master-to/#master_use_gtid).
|
|
|
|
- Time lag behind the master's state (in seconds).
|
|
|
|
- Available since MariaDB 10.0.2.
|
|
|
|
- Available from MySQL 5.6.
|
|
|
|
choices: [current_pos, slave_pos, disabled]
|
|
|
|
- For more information see U(https://dev.mysql.com/doc/refman/8.0/en/replication-delayed.html).
|
|
|
|
type: str
|
|
|
|
type: int
|
|
|
|
version_added: '2.10'
|
|
|
|
version_added: "2.10"
|
|
|
|
master_delay:
|
|
|
|
connection_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Time lag behind the master's state (in seconds).
|
|
|
|
- Name of the master connection.
|
|
|
|
- Available from MySQL 5.6.
|
|
|
|
- Supported from MariaDB 10.0.1.
|
|
|
|
- For more information see U(https://dev.mysql.com/doc/refman/8.0/en/replication-delayed.html).
|
|
|
|
- For more information see U(https://mariadb.com/kb/en/library/multi-source-replication/).
|
|
|
|
type: int
|
|
|
|
type: str
|
|
|
|
version_added: '2.10'
|
|
|
|
version_added: "2.10"
|
|
|
|
connection_name:
|
|
|
|
channel:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the master connection.
|
|
|
|
- Name of replication channel.
|
|
|
|
- Supported from MariaDB 10.0.1.
|
|
|
|
- Multi-source replication is supported from MySQL 5.7.
|
|
|
|
- Mutually exclusive with I(channel).
|
|
|
|
- For more information see U(https://dev.mysql.com/doc/refman/8.0/en/replication-multi-source.html).
|
|
|
|
- For more information see U(https://mariadb.com/kb/en/library/multi-source-replication/).
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
version_added: "2.10"
|
|
|
|
version_added: '2.10'
|
|
|
|
|
|
|
|
channel:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Name of replication channel.
|
|
|
|
|
|
|
|
- Multi-source replication is supported from MySQL 5.7.
|
|
|
|
|
|
|
|
- Mutually exclusive with I(connection_name).
|
|
|
|
|
|
|
|
- For more information see U(https://dev.mysql.com/doc/refman/8.0/en/replication-multi-source.html).
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
version_added: '2.10'
|
|
|
|
|
|
|
|
|
|
|
|
extends_documentation_fragment:
|
|
|
|
extends_documentation_fragment:
|
|
|
|
- mysql
|
|
|
|
- mysql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seealso:
|
|
|
|
|
|
|
|
- module: mysql_info
|
|
|
|
|
|
|
|
- name: MySQL replication reference
|
|
|
|
|
|
|
|
description: Complete reference of the MySQL replication documentation.
|
|
|
|
|
|
|
|
link: https://dev.mysql.com/doc/refman/8.0/en/replication.html
|
|
|
|
|
|
|
|
- name: MariaDB replication reference
|
|
|
|
|
|
|
|
description: Complete reference of the MariaDB replication documentation.
|
|
|
|
|
|
|
|
link: https://mariadb.com/kb/en/library/setting-up-replication/
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
EXAMPLES = r'''
|
|
|
@ -342,7 +361,10 @@ def main():
|
|
|
|
master_delay=dict(type='int'),
|
|
|
|
master_delay=dict(type='int'),
|
|
|
|
connection_name=dict(type='str'),
|
|
|
|
connection_name=dict(type='str'),
|
|
|
|
channel=dict(type='str'),
|
|
|
|
channel=dict(type='str'),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
mutually_exclusive=[
|
|
|
|
|
|
|
|
['connection_name', 'channel']
|
|
|
|
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
mode = module.params["mode"]
|
|
|
|
mode = module.params["mode"]
|
|
|
|
master_host = module.params["master_host"]
|
|
|
|
master_host = module.params["master_host"]
|
|
|
|