mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-06 10:40:36 -07:00
Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b32380a9e1 | ||
|
34a300d5f0 | ||
|
d9651f37d3 | ||
|
da7e73ef6e | ||
|
5fbac22486 | ||
|
900899740b |
19 changed files with 373 additions and 215 deletions
2
.github/workflows/ansible-test-plugins.yml
vendored
2
.github/workflows/ansible-test-plugins.yml
vendored
|
@ -61,7 +61,7 @@ jobs:
|
|||
- stable-2.9
|
||||
- stable-2.10
|
||||
- stable-2.11
|
||||
- devel
|
||||
#- devel
|
||||
python:
|
||||
- 3.6
|
||||
connector:
|
||||
|
|
|
@ -5,6 +5,63 @@ Community MySQL Collection Release Notes
|
|||
.. contents:: Topics
|
||||
|
||||
|
||||
v2.1.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
This is the minor release of the ``community.mysql`` collection.
|
||||
This changelog contains all changes to the modules in this collection
|
||||
that have been added after the release of ``community.mysql`` 2.0.0.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- mysql_replication - add deprecation warning that the ``Is_Slave`` and ``Is_Master`` return values will be replaced with ``Is_Primary`` and ``Is_Replica`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).
|
||||
- mysql_replication - the choices of the ``state`` option containing ``master`` will be finally replaced with the alternative ``primary`` choices in ``community.mysql`` 3.0.0, add deprecation warnings (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- mysql_replication - add alternative (``primary``) choices to the ``state`` option choices containing ``master`` (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
- mysql_replication - add the ``Is_Primary`` and ``Is_Replica`` alternatives to the ``Is_Slave`` and ``Is_Master`` return values as a preparation for replacement in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).
|
||||
- mysql_replication - change ``master_`` options to ``primary_`` options, add aliases to keep compatibility (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- mysql - revert changes of connector arguments made in pull request 116 causing the invalid keyword argument error (https://github.com/ansible-collections/community.mysql/pull/116).
|
||||
|
||||
v2.0.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
This is release 2.0.0 of the ``community.mysql`` collection, released on 2021-04-15.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- mysql_replication - the return value ``Is_Slave`` and ``Is_Master`` will be replaced with ``Is_Replica`` and ``Is_Primary`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/145).
|
||||
- mysql_replication - the word ``master`` in messages returned by the module will be replaced with ``primary`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/145).
|
||||
- mysql_replication - the word ``slave`` in messages returned by the module replaced with ``replica`` (https://github.com/ansible-collections/community.mysql/issues/98).
|
||||
- mysql_user - the ``REQUIRESSL`` is an alias for the ``ssl`` key in the ``tls_requires`` option in ``community.mysql`` 2.0.0 and support will be dropped altogether in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/121).
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- mysql module utils - change deprecated connection parameters ``passwd`` and ``db`` to ``password`` and ``database`` (https://github.com/ansible-collections/community.mysql/pull/116).
|
||||
- mysql_collection - introduce codebabse split to handle divergences between MySQL and MariaDB (https://github.com/ansible-collections/community.mysql/pull/103).
|
||||
- mysql_info - add `version.full` and `version.suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).
|
||||
- mysql_user - deprecate the ``REQUIRESSL`` privilege (https://github.com/ansible-collections/community.mysql/issues/101).
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- mysql_user - add support for ``REPLICA MONITOR`` privilege (https://github.com/ansible-collections/community.mysql/issues/105).
|
||||
|
||||
v1.3.0
|
||||
======
|
||||
|
||||
|
|
|
@ -235,3 +235,66 @@ releases:
|
|||
- 107-mysql_user_fix_grant_on_col_handling.yml
|
||||
- 97-mysql_replication_deprecate_offending_terminology.yml
|
||||
release_date: '2021-03-08'
|
||||
2.0.0:
|
||||
changes:
|
||||
bugfixes:
|
||||
- mysql_user - add support for ``REPLICA MONITOR`` privilege (https://github.com/ansible-collections/community.mysql/issues/105).
|
||||
major_changes:
|
||||
- mysql_replication - the return value ``Is_Slave`` and ``Is_Master`` will be
|
||||
replaced with ``Is_Replica`` and ``Is_Primary`` in ``community.mysql`` 3.0.0
|
||||
(https://github.com/ansible-collections/community.mysql/issues/145).
|
||||
- mysql_replication - the word ``master`` in messages returned by the module
|
||||
will be replaced with ``primary`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/145).
|
||||
- mysql_replication - the word ``slave`` in messages returned by the module
|
||||
replaced with ``replica`` (https://github.com/ansible-collections/community.mysql/issues/98).
|
||||
- mysql_user - the ``REQUIRESSL`` is an alias for the ``ssl`` key in the ``tls_requires``
|
||||
option in ``community.mysql`` 2.0.0 and support will be dropped altogether
|
||||
in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/121).
|
||||
minor_changes:
|
||||
- mysql module utils - change deprecated connection parameters ``passwd`` and
|
||||
``db`` to ``password`` and ``database`` (https://github.com/ansible-collections/community.mysql/pull/116).
|
||||
- mysql_collection - introduce codebabse split to handle divergences between
|
||||
MySQL and MariaDB (https://github.com/ansible-collections/community.mysql/pull/103).
|
||||
- mysql_info - add `version.full` and `version.suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).
|
||||
- mysql_user - deprecate the ``REQUIRESSL`` privilege (https://github.com/ansible-collections/community.mysql/issues/101).
|
||||
release_summary: This is release 2.0.0 of the ``community.mysql`` collection,
|
||||
released on 2021-04-15.
|
||||
fragments:
|
||||
- 101-drop-requiressl-support.yml
|
||||
- 103-mysql_and_mariadb_divergence.yml
|
||||
- 108-mysql_priv_add_grant.yml
|
||||
- 115-add_mysql_full_version_suffix_return_var.yml
|
||||
- 116-change_deprecated_connection_ parameters.yml
|
||||
- 144-mysql_replication_remove_slave_from_messages.yml
|
||||
- 2.0.0.yml
|
||||
release_date: '2021-04-15'
|
||||
2.1.0:
|
||||
changes:
|
||||
bugfixes:
|
||||
- mysql - revert changes of connector arguments made in pull request 116 causing
|
||||
the invalid keyword argument error (https://github.com/ansible-collections/community.mysql/pull/116).
|
||||
major_changes:
|
||||
- mysql_replication - add deprecation warning that the ``Is_Slave`` and ``Is_Master``
|
||||
return values will be replaced with ``Is_Primary`` and ``Is_Replica`` in ``community.mysql``
|
||||
3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).
|
||||
- mysql_replication - the choices of the ``state`` option containing ``master``
|
||||
will be finally replaced with the alternative ``primary`` choices in ``community.mysql``
|
||||
3.0.0, add deprecation warnings (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
minor_changes:
|
||||
- mysql_replication - add alternative (``primary``) choices to the ``state``
|
||||
option choices containing ``master`` (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
- mysql_replication - add the ``Is_Primary`` and ``Is_Replica`` alternatives
|
||||
to the ``Is_Slave`` and ``Is_Master`` return values as a preparation for replacement
|
||||
in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).
|
||||
- mysql_replication - change ``master_`` options to ``primary_`` options, add
|
||||
aliases to keep compatibility (https://github.com/ansible-collections/community.mysql/pull/150).
|
||||
release_summary: 'This is the minor release of the ``community.mysql`` collection.
|
||||
|
||||
This changelog contains all changes to the modules in this collection
|
||||
|
||||
that have been added after the release of ``community.mysql`` 2.0.0.'
|
||||
fragments:
|
||||
- 147-mysql_replication_deprecate_ret_vals.yml
|
||||
- 150-mysql_replication_master_related.yml
|
||||
- 153-mysql_revert_connector_changes.yml
|
||||
release_date: '2021-04-23'
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
minor_changes:
|
||||
- mysql_user - deprecate the ``REQUIRESSL`` privilege (https://github.com/ansible-collections/community.mysql/issues/101).
|
||||
major_changes:
|
||||
- mysql_user - the ``REQUIRESSL`` is an alias for the ``ssl`` key in the ``tls_requires`` option in ``community.mysql`` 2.0.0 and support will be dropped altogether in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/121).
|
|
@ -1,2 +0,0 @@
|
|||
minor_changes:
|
||||
- mysql_collection - introduce codebabse split to handle divergences between MySQL and MariaDB (https://github.com/ansible-collections/community.mysql/pull/103).
|
|
@ -1,2 +0,0 @@
|
|||
bugfixes:
|
||||
- mysql_user - add support for ``REPLICA MONITOR`` privilege (https://github.com/ansible-collections/community.mysql/issues/105).
|
|
@ -1,2 +0,0 @@
|
|||
minor_changes:
|
||||
- mysql_info - add `version.full` and `version.suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).
|
|
@ -1,2 +0,0 @@
|
|||
minor_changes:
|
||||
- mysql module utils - change deprecated connection parameters ``passwd`` and ``db`` to ``password`` and ``database`` (https://github.com/ansible-collections/community.mysql/pull/116).
|
|
@ -1,4 +0,0 @@
|
|||
major_changes:
|
||||
- mysql_replication - the word ``slave`` in messages returned by the module replaced with ``replica`` (https://github.com/ansible-collections/community.mysql/issues/98).
|
||||
- mysql_replication - the return value ``Is_Slave`` and ``Is_Master`` will be replaced with ``Is_Replica`` and ``Is_Primary`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/145).
|
||||
- mysql_replication - the word ``master`` in messages returned by the module will be replaced with ``primary`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/issues/145).
|
|
@ -1,6 +1,6 @@
|
|||
namespace: community
|
||||
name: mysql
|
||||
version: 1.3.0
|
||||
version: 2.1.0
|
||||
readme: README.md
|
||||
authors:
|
||||
- Ansible community
|
||||
|
|
|
@ -79,7 +79,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
|||
if login_user is not None:
|
||||
config['user'] = login_user
|
||||
if login_password is not None:
|
||||
config['password'] = login_password
|
||||
config['passwd'] = login_password
|
||||
if ssl_cert is not None:
|
||||
config['ssl']['cert'] = ssl_cert
|
||||
if ssl_key is not None:
|
||||
|
@ -87,7 +87,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
|||
if ssl_ca is not None:
|
||||
config['ssl']['ca'] = ssl_ca
|
||||
if db is not None:
|
||||
config['database'] = db
|
||||
config['db'] = db
|
||||
if connect_timeout is not None:
|
||||
config['connect_timeout'] = connect_timeout
|
||||
if check_hostname is not None:
|
||||
|
|
|
@ -15,7 +15,7 @@ DOCUMENTATION = r'''
|
|||
module: mysql_replication
|
||||
short_description: Manage MySQL replication
|
||||
description:
|
||||
- Manages MySQL server replication, replica, master status, get and change master host.
|
||||
- Manages MySQL server replication, replica, primary status, get and change primary host.
|
||||
author:
|
||||
- Balazs Pocze (@banyek)
|
||||
- Andrew Klychkov (@Andersson007)
|
||||
|
@ -23,17 +23,19 @@ options:
|
|||
mode:
|
||||
description:
|
||||
- Module operating mode. Could be
|
||||
C(changemaster) (CHANGE MASTER TO),
|
||||
C(getmaster) (SHOW MASTER STATUS),
|
||||
C(changeprimary | changemaster) (CHANGE PRIMARY | MASTER TO),
|
||||
C(getprimary | getmaster) (SHOW PRIMARY | MASTER STATUS),
|
||||
C(getreplica | getslave) (SHOW REPLICA | SLAVE STATUS),
|
||||
C(startreplica | startslave) (START REPLICA | SLAVE),
|
||||
C(stopreplica | stopslave) (STOP REPLICA | SLAVE),
|
||||
C(resetmaster) (RESET MASTER) - supported since community.mysql 0.1.0,
|
||||
C(resetprimary | resetmaster) (RESET PRIMARY | MASTER) - supported since community.mysql 0.1.0,
|
||||
C(resetreplica, resetslave) (RESET REPLICA | SLAVE),
|
||||
C(resetreplicaall, resetslave) (RESET REPLICA | SLAVE ALL).
|
||||
type: str
|
||||
choices:
|
||||
- changeprimary
|
||||
- changemaster
|
||||
- getprimary
|
||||
- getmaster
|
||||
- getreplica
|
||||
- getslave
|
||||
|
@ -41,40 +43,48 @@ options:
|
|||
- startslave
|
||||
- stopreplica
|
||||
- stopslave
|
||||
- resetprimary
|
||||
- resetmaster
|
||||
- resetreplica
|
||||
- resetslave
|
||||
- resetreplicaall
|
||||
- resetslaveall
|
||||
default: getreplica
|
||||
master_host:
|
||||
primary_host:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_HOST) mysql variable.
|
||||
type: str
|
||||
master_user:
|
||||
aliases: [master_host]
|
||||
primary_user:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_USER) mysql variable.
|
||||
type: str
|
||||
master_password:
|
||||
aliases: [master_user]
|
||||
primary_password:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_PASSWORD) mysql variable.
|
||||
type: str
|
||||
master_port:
|
||||
aliases: [master_password]
|
||||
primary_port:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_PORT) mysql variable.
|
||||
type: int
|
||||
master_connect_retry:
|
||||
aliases: [master_port]
|
||||
primary_connect_retry:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_CONNECT_RETRY) mysql variable.
|
||||
type: int
|
||||
master_log_file:
|
||||
aliases: [master_connect_retry]
|
||||
primary_log_file:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_LOG_FILE) mysql variable.
|
||||
type: str
|
||||
master_log_pos:
|
||||
aliases: [master_log_file]
|
||||
primary_log_pos:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
- Same as the C(MASTER_LOG_POS) mysql variable.
|
||||
type: int
|
||||
aliases: [master_log_pos]
|
||||
relay_log_file:
|
||||
description:
|
||||
- Same as mysql variable.
|
||||
|
@ -83,7 +93,7 @@ options:
|
|||
description:
|
||||
- Same as mysql variable.
|
||||
type: int
|
||||
master_ssl:
|
||||
primary_ssl:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL) mysql variable.
|
||||
- When setting it to C(yes), the connection attempt only succeeds
|
||||
|
@ -92,43 +102,51 @@ options:
|
|||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: bool
|
||||
default: false
|
||||
master_ssl_ca:
|
||||
aliases: [master_ssl]
|
||||
primary_ssl_ca:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL_CA) mysql variable.
|
||||
- For details, refer to
|
||||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: str
|
||||
master_ssl_capath:
|
||||
aliases: [master_ssl_ca]
|
||||
primary_ssl_capath:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL_CAPATH) mysql variable.
|
||||
- For details, refer to
|
||||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: str
|
||||
master_ssl_cert:
|
||||
aliases: [master_ssl_capath]
|
||||
primary_ssl_cert:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL_CERT) mysql variable.
|
||||
- For details, refer to
|
||||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: str
|
||||
master_ssl_key:
|
||||
aliases: [master_ssl_cert]
|
||||
primary_ssl_key:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL_KEY) mysql variable.
|
||||
- For details, refer to
|
||||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: str
|
||||
master_ssl_cipher:
|
||||
aliases: [master_ssl_key]
|
||||
primary_ssl_cipher:
|
||||
description:
|
||||
- Same as the C(MASTER_SSL_CIPHER) mysql variable.
|
||||
- Specifies a colon-separated list of one or more ciphers permitted by the replica for the replication connection.
|
||||
- For details, refer to
|
||||
L(MySQL encrypted replication documentation,https://dev.mysql.com/doc/refman/8.0/en/replication-solutions-encrypted-connections.html).
|
||||
type: str
|
||||
master_auto_position:
|
||||
aliases: [master_ssl_cipher]
|
||||
primary_auto_position:
|
||||
description:
|
||||
- Whether the host uses GTID based replication or not.
|
||||
- Same as the C(MASTER_AUTO_POSITION) mysql variable.
|
||||
type: bool
|
||||
default: false
|
||||
master_use_gtid:
|
||||
aliases: [master_auto_position]
|
||||
primary_use_gtid:
|
||||
description:
|
||||
- Configures the replica to use the MariaDB Global Transaction ID.
|
||||
- C(disabled) equals MASTER_USE_GTID=no command.
|
||||
|
@ -140,16 +158,19 @@ options:
|
|||
choices: [current_pos, replica_pos, slave_pos, disabled]
|
||||
type: str
|
||||
version_added: '0.1.0'
|
||||
master_delay:
|
||||
aliases: [master_use_gtid]
|
||||
primary_delay:
|
||||
description:
|
||||
- Time lag behind the master's state (in seconds).
|
||||
- Time lag behind the primary's state (in seconds).
|
||||
- Same as the C(MASTER_DELAY) mysql variable.
|
||||
- Available from MySQL 5.6.
|
||||
- For more information see U(https://dev.mysql.com/doc/refman/8.0/en/replication-delayed.html).
|
||||
type: int
|
||||
version_added: '0.1.0'
|
||||
aliases: [master_delay]
|
||||
connection_name:
|
||||
description:
|
||||
- Name of the master connection.
|
||||
- Name of the primary connection.
|
||||
- Supported from MariaDB 10.0.1.
|
||||
- Mutually exclusive with I(channel).
|
||||
- For more information see U(https://mariadb.com/kb/en/library/multi-source-replication/).
|
||||
|
@ -195,16 +216,16 @@ EXAMPLES = r'''
|
|||
community.mysql.mysql_replication:
|
||||
mode: stopreplica
|
||||
|
||||
- name: Get master binlog file name and binlog position
|
||||
- name: Get primary binlog file name and binlog position
|
||||
community.mysql.mysql_replication:
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
|
||||
- name: Change master to master server 192.0.2.1 and use binary log 'mysql-bin.000009' with position 4578
|
||||
- name: Change primary to primary server 192.0.2.1 and use binary log 'mysql-bin.000009' with position 4578
|
||||
community.mysql.mysql_replication:
|
||||
mode: changemaster
|
||||
master_host: 192.0.2.1
|
||||
master_log_file: mysql-bin.000009
|
||||
master_log_pos: 4578
|
||||
mode: changeprimary
|
||||
primary_host: 192.0.2.1
|
||||
primary_log_file: mysql-bin.000009
|
||||
primary_log_pos: 4578
|
||||
|
||||
- name: Check replica status using port 3308
|
||||
community.mysql.mysql_replication:
|
||||
|
@ -212,42 +233,42 @@ EXAMPLES = r'''
|
|||
login_host: ansible.example.com
|
||||
login_port: 3308
|
||||
|
||||
- name: On MariaDB change master to use GTID current_pos
|
||||
- name: On MariaDB change primary to use GTID current_pos
|
||||
community.mysql.mysql_replication:
|
||||
mode: changemaster
|
||||
master_use_gtid: current_pos
|
||||
mode: changeprimary
|
||||
primary_use_gtid: current_pos
|
||||
|
||||
- name: Change master to use replication delay 3600 seconds
|
||||
- name: Change primary to use replication delay 3600 seconds
|
||||
community.mysql.mysql_replication:
|
||||
mode: changemaster
|
||||
master_host: 192.0.2.1
|
||||
master_delay: 3600
|
||||
mode: changeprimary
|
||||
primary_host: 192.0.2.1
|
||||
primary_delay: 3600
|
||||
|
||||
- name: Start MariaDB replica with connection name master-1
|
||||
- name: Start MariaDB replica with connection name primary-1
|
||||
community.mysql.mysql_replication:
|
||||
mode: startreplica
|
||||
connection_name: master-1
|
||||
connection_name: primary-1
|
||||
|
||||
- name: Stop replication in channel master-1
|
||||
- name: Stop replication in channel primary-1
|
||||
community.mysql.mysql_replication:
|
||||
mode: stopreplica
|
||||
channel: master-1
|
||||
channel: primary-1
|
||||
|
||||
- name: >
|
||||
Run RESET MASTER command which will delete all existing binary log files
|
||||
and reset the binary log index file on the master
|
||||
and reset the binary log index file on the primary
|
||||
community.mysql.mysql_replication:
|
||||
mode: resetmaster
|
||||
mode: resetprimary
|
||||
|
||||
- name: Run start replica and fail the task on errors
|
||||
community.mysql.mysql_replication:
|
||||
mode: startreplica
|
||||
connection_name: master-1
|
||||
connection_name: primary-1
|
||||
fail_on_error: yes
|
||||
|
||||
- name: Change master and fail on error (like when replica thread is running)
|
||||
- name: Change primary and fail on error (like when replica thread is running)
|
||||
community.mysql.mysql_replication:
|
||||
mode: changemaster
|
||||
mode: changeprimary
|
||||
fail_on_error: yes
|
||||
|
||||
'''
|
||||
|
@ -257,7 +278,7 @@ queries:
|
|||
description: List of executed queries which modified DB's state.
|
||||
returned: always
|
||||
type: list
|
||||
sample: ["CHANGE MASTER TO MASTER_HOST='master2.example.com',MASTER_PORT=3306"]
|
||||
sample: ["CHANGE MASTER TO MASTER_HOST='primary2.example.com',MASTER_PORT=3306"]
|
||||
version_added: '0.1.0'
|
||||
'''
|
||||
|
||||
|
@ -277,10 +298,13 @@ from distutils.version import LooseVersion
|
|||
executed_queries = []
|
||||
|
||||
|
||||
def get_master_status(cursor):
|
||||
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")
|
||||
masterstatus = cursor.fetchone()
|
||||
return masterstatus
|
||||
primarystatus = cursor.fetchone()
|
||||
return primarystatus
|
||||
|
||||
|
||||
def get_replica_status(cursor, connection_name='', channel='', term='REPLICA'):
|
||||
|
@ -363,7 +387,7 @@ def reset_replica_all(module, cursor, connection_name='', channel='', fail_on_er
|
|||
return reset
|
||||
|
||||
|
||||
def reset_master(module, cursor, fail_on_error=False):
|
||||
def reset_primary(module, cursor, fail_on_error=False):
|
||||
query = 'RESET MASTER'
|
||||
try:
|
||||
executed_queries.append(query)
|
||||
|
@ -400,7 +424,7 @@ def start_replica(module, cursor, connection_name='', channel='', fail_on_error=
|
|||
return started
|
||||
|
||||
|
||||
def changemaster(cursor, chm, connection_name='', channel=''):
|
||||
def changeprimary(cursor, chm, connection_name='', channel=''):
|
||||
if connection_name:
|
||||
query = "CHANGE MASTER '%s' TO %s" % (connection_name, ','.join(chm))
|
||||
else:
|
||||
|
@ -417,29 +441,33 @@ def main():
|
|||
argument_spec = mysql_common_argument_spec()
|
||||
argument_spec.update(
|
||||
mode=dict(type='str', default='getreplica', choices=[
|
||||
'getmaster', 'getreplica', 'getslave', 'changemaster',
|
||||
'stopreplica', 'stopslave', 'startreplica', 'startslave',
|
||||
'resetmaster', 'resetreplica', 'resetslave',
|
||||
'getprimary', 'getmaster',
|
||||
'getreplica', 'getslave',
|
||||
'changeprimary', 'changemaster',
|
||||
'stopreplica', 'stopslave',
|
||||
'startreplica', 'startslave',
|
||||
'resetprimary', 'resetmaster',
|
||||
'resetreplica', 'resetslave',
|
||||
'resetreplicaall', 'resetslaveall']),
|
||||
master_auto_position=dict(type='bool', default=False),
|
||||
master_host=dict(type='str'),
|
||||
master_user=dict(type='str'),
|
||||
master_password=dict(type='str', no_log=True),
|
||||
master_port=dict(type='int'),
|
||||
master_connect_retry=dict(type='int'),
|
||||
master_log_file=dict(type='str'),
|
||||
master_log_pos=dict(type='int'),
|
||||
primary_auto_position=dict(type='bool', default=False, aliases=['master_auto_position']),
|
||||
primary_host=dict(type='str', aliases=['master_host']),
|
||||
primary_user=dict(type='str', aliases=['master_user']),
|
||||
primary_password=dict(type='str', no_log=True, aliases=['master_password']),
|
||||
primary_port=dict(type='int', aliases=['master_port']),
|
||||
primary_connect_retry=dict(type='int', aliases=['master_connect_retry']),
|
||||
primary_log_file=dict(type='str', aliases=['master_log_file']),
|
||||
primary_log_pos=dict(type='int', aliases=['master_log_pos']),
|
||||
relay_log_file=dict(type='str'),
|
||||
relay_log_pos=dict(type='int'),
|
||||
master_ssl=dict(type='bool', default=False),
|
||||
master_ssl_ca=dict(type='str'),
|
||||
master_ssl_capath=dict(type='str'),
|
||||
master_ssl_cert=dict(type='str'),
|
||||
master_ssl_key=dict(type='str', no_log=False),
|
||||
master_ssl_cipher=dict(type='str'),
|
||||
master_use_gtid=dict(type='str', choices=[
|
||||
'current_pos', 'replica_pos', 'slave_pos', 'disabled']),
|
||||
master_delay=dict(type='int'),
|
||||
primary_ssl=dict(type='bool', default=False, aliases=['master_ssl']),
|
||||
primary_ssl_ca=dict(type='str', aliases=['master_ssl_ca']),
|
||||
primary_ssl_capath=dict(type='str', aliases=['master_ssl_capath']),
|
||||
primary_ssl_cert=dict(type='str', aliases=['master_ssl_cert']),
|
||||
primary_ssl_key=dict(type='str', no_log=False, aliases=['master_ssl_key']),
|
||||
primary_ssl_cipher=dict(type='str', aliases=['master_ssl_cipher']),
|
||||
primary_use_gtid=dict(type='str', choices=[
|
||||
'current_pos', 'replica_pos', 'slave_pos', 'disabled'], aliases=['master_use_gtid']),
|
||||
primary_delay=dict(type='int', aliases=['master_delay']),
|
||||
connection_name=dict(type='str'),
|
||||
channel=dict(type='str'),
|
||||
fail_on_error=dict(type='bool', default=False),
|
||||
|
@ -451,33 +479,33 @@ def main():
|
|||
],
|
||||
)
|
||||
mode = module.params["mode"]
|
||||
master_host = module.params["master_host"]
|
||||
master_user = module.params["master_user"]
|
||||
master_password = module.params["master_password"]
|
||||
master_port = module.params["master_port"]
|
||||
master_connect_retry = module.params["master_connect_retry"]
|
||||
master_log_file = module.params["master_log_file"]
|
||||
master_log_pos = module.params["master_log_pos"]
|
||||
primary_host = module.params["primary_host"]
|
||||
primary_user = module.params["primary_user"]
|
||||
primary_password = module.params["primary_password"]
|
||||
primary_port = module.params["primary_port"]
|
||||
primary_connect_retry = module.params["primary_connect_retry"]
|
||||
primary_log_file = module.params["primary_log_file"]
|
||||
primary_log_pos = module.params["primary_log_pos"]
|
||||
relay_log_file = module.params["relay_log_file"]
|
||||
relay_log_pos = module.params["relay_log_pos"]
|
||||
master_ssl = module.params["master_ssl"]
|
||||
master_ssl_ca = module.params["master_ssl_ca"]
|
||||
master_ssl_capath = module.params["master_ssl_capath"]
|
||||
master_ssl_cert = module.params["master_ssl_cert"]
|
||||
master_ssl_key = module.params["master_ssl_key"]
|
||||
master_ssl_cipher = module.params["master_ssl_cipher"]
|
||||
master_auto_position = module.params["master_auto_position"]
|
||||
primary_ssl = module.params["primary_ssl"]
|
||||
primary_ssl_ca = module.params["primary_ssl_ca"]
|
||||
primary_ssl_capath = module.params["primary_ssl_capath"]
|
||||
primary_ssl_cert = module.params["primary_ssl_cert"]
|
||||
primary_ssl_key = module.params["primary_ssl_key"]
|
||||
primary_ssl_cipher = module.params["primary_ssl_cipher"]
|
||||
primary_auto_position = module.params["primary_auto_position"]
|
||||
ssl_cert = module.params["client_cert"]
|
||||
ssl_key = module.params["client_key"]
|
||||
ssl_ca = module.params["ca_cert"]
|
||||
check_hostname = module.params["check_hostname"]
|
||||
connect_timeout = module.params['connect_timeout']
|
||||
config_file = module.params['config_file']
|
||||
master_delay = module.params['master_delay']
|
||||
if module.params.get("master_use_gtid") == 'disabled':
|
||||
master_use_gtid = 'no'
|
||||
primary_delay = module.params['primary_delay']
|
||||
if module.params.get("primary_use_gtid") == 'disabled':
|
||||
primary_use_gtid = 'no'
|
||||
else:
|
||||
master_use_gtid = module.params["master_use_gtid"]
|
||||
primary_use_gtid = module.params["primary_use_gtid"]
|
||||
connection_name = module.params["connection_name"]
|
||||
channel = module.params['channel']
|
||||
fail_on_error = module.params['fail_on_error']
|
||||
|
@ -512,21 +540,35 @@ def main():
|
|||
# "REPLICA" must be used instead of "SLAVE"
|
||||
if impl.uses_replica_terminology(cursor):
|
||||
replica_term = 'REPLICA'
|
||||
if master_use_gtid == 'slave_pos':
|
||||
module.deprecate('master_use_gtid "slave_pos" value is deprecated, use "replica_pos" instead.',
|
||||
if primary_use_gtid == 'slave_pos':
|
||||
module.deprecate('primary_use_gtid | master_use_gtid "slave_pos" value is '
|
||||
'deprecated, use "replica_pos" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
master_use_gtid = 'replica_pos'
|
||||
primary_use_gtid = 'replica_pos'
|
||||
else:
|
||||
replica_term = 'SLAVE'
|
||||
if master_use_gtid == 'replica_pos':
|
||||
master_use_gtid = 'slave_pos'
|
||||
if primary_use_gtid == 'replica_pos':
|
||||
primary_use_gtid = 'slave_pos'
|
||||
|
||||
if mode in "getmaster":
|
||||
status = get_master_status(cursor)
|
||||
if mode in ('getprimary', 'getmaster'):
|
||||
if mode == 'getmaster':
|
||||
module.deprecate('"getmaster" option is deprecated, use "getprimary" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
|
||||
status = get_primary_status(cursor)
|
||||
if not isinstance(status, dict):
|
||||
status = dict(Is_Master=False, msg="Server is not configured as mysql master")
|
||||
# TODO: change the word master to primary in 3.0.0
|
||||
status = dict(Is_Master=False, Is_Primary=False,
|
||||
msg="Server is not configured as mysql master")
|
||||
else:
|
||||
status['Is_Master'] = True
|
||||
status['Is_Primary'] = True
|
||||
|
||||
module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
|
||||
'and will be replaced with "Is_Primary" and "Is_Replica" '
|
||||
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
|
||||
module.exit_json(queries=executed_queries, **status)
|
||||
|
||||
elif mode in ("getreplica", "getslave"):
|
||||
|
@ -536,56 +578,62 @@ def main():
|
|||
|
||||
status = get_replica_status(cursor, connection_name, channel, replica_term)
|
||||
if not isinstance(status, dict):
|
||||
# TODO: announce it and replace with Replica
|
||||
# in the next major release. Maybe a warning?
|
||||
status = dict(Is_Slave=False, msg="Server is not configured as mysql replica")
|
||||
status = dict(Is_Slave=False, Is_Replica=False, msg="Server is not configured as mysql replica")
|
||||
else:
|
||||
# TODO: announce it and replace with Replica
|
||||
# in the next major release. Maybe a warning?
|
||||
status['Is_Slave'] = True
|
||||
status['Is_Replica'] = True
|
||||
|
||||
module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
|
||||
'and will be replaced with "Is_Primary" and "Is_Replica" '
|
||||
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
|
||||
module.exit_json(queries=executed_queries, **status)
|
||||
|
||||
elif mode in "changemaster":
|
||||
elif mode in ('changeprimary', 'changemaster'):
|
||||
if mode == 'changemaster':
|
||||
module.deprecate('"changemaster" option is deprecated, use "changeprimary" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
chm = []
|
||||
result = {}
|
||||
if master_host is not None:
|
||||
chm.append("MASTER_HOST='%s'" % master_host)
|
||||
if master_user is not None:
|
||||
chm.append("MASTER_USER='%s'" % master_user)
|
||||
if master_password is not None:
|
||||
chm.append("MASTER_PASSWORD='%s'" % master_password)
|
||||
if master_port is not None:
|
||||
chm.append("MASTER_PORT=%s" % master_port)
|
||||
if master_connect_retry is not None:
|
||||
chm.append("MASTER_CONNECT_RETRY=%s" % master_connect_retry)
|
||||
if master_log_file is not None:
|
||||
chm.append("MASTER_LOG_FILE='%s'" % master_log_file)
|
||||
if master_log_pos is not None:
|
||||
chm.append("MASTER_LOG_POS=%s" % master_log_pos)
|
||||
if master_delay is not None:
|
||||
chm.append("MASTER_DELAY=%s" % master_delay)
|
||||
if primary_host is not None:
|
||||
chm.append("MASTER_HOST='%s'" % primary_host)
|
||||
if primary_user is not None:
|
||||
chm.append("MASTER_USER='%s'" % primary_user)
|
||||
if primary_password is not None:
|
||||
chm.append("MASTER_PASSWORD='%s'" % primary_password)
|
||||
if primary_port is not None:
|
||||
chm.append("MASTER_PORT=%s" % primary_port)
|
||||
if primary_connect_retry is not None:
|
||||
chm.append("MASTER_CONNECT_RETRY=%s" % primary_connect_retry)
|
||||
if primary_log_file is not None:
|
||||
chm.append("MASTER_LOG_FILE='%s'" % primary_log_file)
|
||||
if primary_log_pos is not None:
|
||||
chm.append("MASTER_LOG_POS=%s" % primary_log_pos)
|
||||
if primary_delay is not None:
|
||||
chm.append("MASTER_DELAY=%s" % primary_delay)
|
||||
if relay_log_file is not None:
|
||||
chm.append("RELAY_LOG_FILE='%s'" % relay_log_file)
|
||||
if relay_log_pos is not None:
|
||||
chm.append("RELAY_LOG_POS=%s" % relay_log_pos)
|
||||
if master_ssl:
|
||||
if primary_ssl:
|
||||
chm.append("MASTER_SSL=1")
|
||||
if master_ssl_ca is not None:
|
||||
chm.append("MASTER_SSL_CA='%s'" % master_ssl_ca)
|
||||
if master_ssl_capath is not None:
|
||||
chm.append("MASTER_SSL_CAPATH='%s'" % master_ssl_capath)
|
||||
if master_ssl_cert is not None:
|
||||
chm.append("MASTER_SSL_CERT='%s'" % master_ssl_cert)
|
||||
if master_ssl_key is not None:
|
||||
chm.append("MASTER_SSL_KEY='%s'" % master_ssl_key)
|
||||
if master_ssl_cipher is not None:
|
||||
chm.append("MASTER_SSL_CIPHER='%s'" % master_ssl_cipher)
|
||||
if master_auto_position:
|
||||
if primary_ssl_ca is not None:
|
||||
chm.append("MASTER_SSL_CA='%s'" % primary_ssl_ca)
|
||||
if primary_ssl_capath is not None:
|
||||
chm.append("MASTER_SSL_CAPATH='%s'" % primary_ssl_capath)
|
||||
if primary_ssl_cert is not None:
|
||||
chm.append("MASTER_SSL_CERT='%s'" % primary_ssl_cert)
|
||||
if primary_ssl_key is not None:
|
||||
chm.append("MASTER_SSL_KEY='%s'" % primary_ssl_key)
|
||||
if primary_ssl_cipher is not None:
|
||||
chm.append("MASTER_SSL_CIPHER='%s'" % primary_ssl_cipher)
|
||||
if primary_auto_position:
|
||||
chm.append("MASTER_AUTO_POSITION=1")
|
||||
if master_use_gtid is not None:
|
||||
chm.append("MASTER_USE_GTID=%s" % master_use_gtid)
|
||||
if primary_use_gtid is not None:
|
||||
chm.append("MASTER_USE_GTID=%s" % primary_use_gtid)
|
||||
try:
|
||||
changemaster(cursor, chm, connection_name, channel)
|
||||
changeprimary(cursor, chm, connection_name, channel)
|
||||
except mysql_driver.Warning as e:
|
||||
result['warning'] = to_native(e)
|
||||
except Exception as e:
|
||||
|
@ -612,11 +660,17 @@ def main():
|
|||
module.exit_json(msg="Replica stopped", changed=True, queries=executed_queries)
|
||||
else:
|
||||
module.exit_json(msg="Replica already stopped", changed=False, queries=executed_queries)
|
||||
elif mode in "resetmaster":
|
||||
reset = reset_master(module, cursor, fail_on_error)
|
||||
elif mode in ('resetprimary', 'resetmaster'):
|
||||
if mode == 'resetmaster':
|
||||
module.deprecate('"resetmaster" option is deprecated, use "resetprimary" instead.',
|
||||
version='3.0.0', collection_name='community.mysql')
|
||||
|
||||
reset = reset_primary(module, cursor, fail_on_error)
|
||||
if reset is True:
|
||||
# TODO: Change "Master" to "Primary" in release 3.0.0
|
||||
module.exit_json(msg="Master reset", changed=True, queries=executed_queries)
|
||||
else:
|
||||
# TODO: Change "Master" to "Primary" in release 3.0.0
|
||||
module.exit_json(msg="Master already reset", changed=False, queries=executed_queries)
|
||||
elif mode in ("resetreplica", "resetslave"):
|
||||
if mode == "resetslave":
|
||||
|
|
|
@ -7,7 +7,7 @@ mysql_replica2_port: 3309
|
|||
|
||||
test_db: test_db
|
||||
test_table: test_table
|
||||
test_master_delay: 60
|
||||
test_primary_delay: 60
|
||||
replication_user: replication_user
|
||||
replication_pass: replication_pass
|
||||
dump_path: /tmp/dump.sql
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
- name: attempt connection with newly created user (expect failure)
|
||||
mysql_replication:
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
login_user: '{{ user_name_1 }}'
|
||||
login_password: '{{ user_password_1 }}'
|
||||
login_host: 127.0.0.1
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
- name: attempt connection with newly created user ignoring hostname
|
||||
mysql_replication:
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
login_user: '{{ user_name_1 }}'
|
||||
login_password: '{{ user_password_1 }}'
|
||||
login_host: 127.0.0.1
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
# Initial CI tests of mysql_replication module:
|
||||
- import_tasks: mysql_replication_initial.yml
|
||||
|
||||
# Tests of master_delay parameter:
|
||||
- import_tasks: mysql_replication_master_delay.yml
|
||||
# Tests of primary_delay parameter:
|
||||
- import_tasks: mysql_replication_primary_delay.yml
|
||||
|
||||
# Tests of channel parameter:
|
||||
- import_tasks: mysql_replication_channel.yml
|
||||
|
||||
# Tests of resetmaster mode:
|
||||
- import_tasks: mysql_replication_resetmaster_mode.yml
|
||||
# Tests of resetprimary mode:
|
||||
- import_tasks: mysql_replication_resetprimary_mode.yml
|
||||
|
||||
- include: issue-28.yml
|
||||
|
|
|
@ -8,26 +8,26 @@
|
|||
login_host: 127.0.0.1
|
||||
|
||||
block:
|
||||
# Get master log file and log pos:
|
||||
- name: Get master status
|
||||
# Get primary log file and log pos:
|
||||
- name: Get primary status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
register: mysql_primary_status
|
||||
|
||||
# Test changemaster mode:
|
||||
# Test changeprimary mode:
|
||||
- name: Run replication with channel
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica2_port }}'
|
||||
mode: changemaster
|
||||
master_host: '{{ mysql_host }}'
|
||||
master_port: '{{ mysql_primary_port }}'
|
||||
master_user: '{{ replication_user }}'
|
||||
master_password: '{{ replication_pass }}'
|
||||
master_log_file: '{{ mysql_primary_status.File }}'
|
||||
master_log_pos: '{{ mysql_primary_status.Position }}'
|
||||
mode: changeprimary
|
||||
primary_host: '{{ mysql_host }}'
|
||||
primary_port: '{{ mysql_primary_port }}'
|
||||
primary_user: '{{ replication_user }}'
|
||||
primary_password: '{{ replication_pass }}'
|
||||
primary_log_file: '{{ mysql_primary_status.File }}'
|
||||
primary_log_pos: '{{ mysql_primary_status.Position }}'
|
||||
channel: '{{ test_channel }}'
|
||||
register: result
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- replica_status.Is_Slave == true
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Master_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Master_Port == {{ mysql_primary_port }}
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- replica_status.Is_Slave == true
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Source_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Source_Port == {{ mysql_primary_port }}
|
||||
|
|
|
@ -49,22 +49,22 @@
|
|||
- name: Restore the dump to replica2
|
||||
shell: '{{ mysql_command }} -P{{ mysql_replica2_port }} < {{ dump_path }}'
|
||||
|
||||
# Test getmaster mode:
|
||||
- name: Get master status
|
||||
# Test getprimary mode:
|
||||
- name: Get primary status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
register: mysql_primary_status
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- mysql_primary_status.Is_Master == true
|
||||
- mysql_primary_status.Is_Primary == true
|
||||
- mysql_primary_status.Position != 0
|
||||
- mysql_primary_status is not changed
|
||||
|
||||
# Test startreplica fails without changemaster first. This needs fail_on_error
|
||||
- name: Start replica (using deprecated startslave choice) and fail because master is not specified; failing on error as requested
|
||||
# Test startreplica fails without changeprimary first. This needs fail_on_error
|
||||
- name: Start replica (using deprecated startslave choice) and fail because primary is not specified; failing on error as requested
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica1_port }}'
|
||||
|
@ -103,21 +103,21 @@
|
|||
that:
|
||||
- result is not failed
|
||||
|
||||
# Test changemaster mode:
|
||||
# master_ssl_ca will be set as '' to check the module's behaviour for #23976,
|
||||
# Test changeprimary mode:
|
||||
# primary_ssl_ca will be set as '' to check the module's behaviour for #23976,
|
||||
# must be converted to an empty string
|
||||
- name: Run replication
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica1_port }}'
|
||||
mode: changemaster
|
||||
master_host: '{{ mysql_host }}'
|
||||
master_port: '{{ mysql_primary_port }}'
|
||||
master_user: '{{ replication_user }}'
|
||||
master_password: '{{ replication_pass }}'
|
||||
master_log_file: '{{ mysql_primary_status.File }}'
|
||||
master_log_pos: '{{ mysql_primary_status.Position }}'
|
||||
master_ssl_ca: ''
|
||||
mode: changeprimary
|
||||
primary_host: '{{ mysql_host }}'
|
||||
primary_port: '{{ mysql_primary_port }}'
|
||||
primary_user: '{{ replication_user }}'
|
||||
primary_password: '{{ replication_pass }}'
|
||||
primary_log_file: '{{ mysql_primary_status.File }}'
|
||||
primary_log_pos: '{{ mysql_primary_status.Position }}'
|
||||
primary_ssl_ca: ''
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -148,7 +148,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- replica_status.Is_Slave == true
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Master_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Master_Port == {{ mysql_primary_port }}
|
||||
|
@ -179,7 +179,7 @@
|
|||
pause:
|
||||
seconds: 2
|
||||
|
||||
# Test master log pos has been changed:
|
||||
# Test primary log pos has been changed:
|
||||
- name: Get replica status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
block:
|
||||
|
||||
# Test master_delay mode:
|
||||
# Test primary_delay mode:
|
||||
- name: Run replication
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica1_port }}'
|
||||
mode: changemaster
|
||||
master_delay: '{{ test_master_delay }}'
|
||||
mode: changeprimary
|
||||
primary_delay: '{{ test_primary_delay }}'
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -31,7 +31,7 @@
|
|||
mode: startreplica
|
||||
register: result
|
||||
|
||||
# Check master_delay:
|
||||
# Check primary_delay:
|
||||
- name: Get standby status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
|
@ -41,5 +41,5 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- replica_status.SQL_Delay == {{ test_master_delay }}
|
||||
- replica_status.SQL_Delay == {{ test_primary_delay }}
|
||||
- replica_status is not changed
|
|
@ -22,20 +22,20 @@
|
|||
login_port: '{{ mysql_replica1_port }}'
|
||||
mode: resetreplicaall
|
||||
|
||||
# Get master initial status:
|
||||
- name: Get master status
|
||||
# Get primary initial status:
|
||||
- name: Get primary status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
register: mysql_primary_initial_status
|
||||
|
||||
# Test resetmaster mode:
|
||||
- name: Reset master
|
||||
# Test resetprimary mode:
|
||||
- name: Reset primary
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
mode: resetmaster
|
||||
mode: resetprimary
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -43,12 +43,12 @@
|
|||
- result is changed
|
||||
- result.queries == ["RESET MASTER"]
|
||||
|
||||
# Get master final status:
|
||||
- name: Get master status
|
||||
# Get primary final status:
|
||||
- name: Get primary status
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
mode: getmaster
|
||||
mode: getprimary
|
||||
register: mysql_primary_final_status
|
||||
|
||||
- assert:
|
Loading…
Add table
Reference in a new issue