Skip to content

Commit bc19516

Browse files
Add missing options to CHANGE MASTER TO
1 parent bb99cf5 commit bc19516

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- mysql_replication - add missing CHANGE MASTER TO options (https://github.com/ansible-collections/community.mysql/issues/59).

plugins/modules/mysql_replication.py

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
author:
2020
- Balazs Pocze (@banyek)
2121
- Andrew Klychkov (@Andersson007)
22+
- Jorge Rodriguez (@Jorge-Rodriguez)
2223
options:
2324
mode:
2425
description:
@@ -42,6 +43,11 @@
4243
- resetslave
4344
- resetslaveall
4445
default: getslave
46+
master_bind:
47+
description:
48+
- same as mysql_variable.
49+
type: str
50+
version_added: 1.2.0
4551
master_host:
4652
description:
4753
- Same as mysql variable.
@@ -58,10 +64,20 @@
5864
description:
5965
- Same as mysql variable.
6066
type: int
67+
master_heartbeat_period:
68+
description:
69+
- Same as mysql variable.
70+
type: int
71+
version_added: 1.2.0
6172
master_connect_retry:
6273
description:
6374
- Same as mysql variable.
6475
type: int
76+
master_retry_count:
77+
description:
78+
- Same as mysql variable.
79+
type: int
80+
version_added: 1.2.0
6581
master_log_file:
6682
description:
6783
- Same as mysql variable.
@@ -94,6 +110,16 @@
94110
description:
95111
- Same as mysql variable.
96112
type: str
113+
master_ssl_crl:
114+
description:
115+
- Same as mysql variable.
116+
type: str
117+
version_added: 1.2.0
118+
master_ssl_crlpath:
119+
description:
120+
- Same as mysql variable.
121+
type: str
122+
version_added: 1.2.0
97123
master_ssl_key:
98124
description:
99125
- Same as mysql variable.
@@ -102,10 +128,38 @@
102128
description:
103129
- Same as mysql variable.
104130
type: str
131+
master_ssl_verify_server_cert:
132+
description:
133+
- Same as mysql variable.
134+
type: bool
135+
version_added: 1.2.0
136+
master_tls_version:
137+
description:
138+
- Same as mysql variable.
139+
type: str
140+
version_added: 1.2.0
105141
master_auto_position:
106142
description:
107143
- Whether the host uses GTID based replication or not.
108144
type: bool
145+
ignore_server_ids:
146+
description:
147+
- List of server IDs whose events are ignored.
148+
type: list
149+
elements: str
150+
version_added: 1.2.0
151+
do_domain_ids:
152+
description:
153+
- Same as MariaDB variable.
154+
type: list
155+
elements: str
156+
version_added: 1.2.0
157+
ignore_domain_ids:
158+
description:
159+
- Same as MariaDB variable.
160+
type: list
161+
elements: str
162+
version_added: 1.2.0
109163
master_use_gtid:
110164
description:
111165
- Configures the slave to use the MariaDB Global Transaction ID.
@@ -131,6 +185,59 @@
131185
- For more information see U(https://mariadb.com/kb/en/library/multi-source-replication/).
132186
type: str
133187
version_added: '0.1.0'
188+
privilege_checks_user:
189+
description:
190+
- Same as mysql variable.
191+
choices: [account]
192+
type: str
193+
version_added: 1.2.0
194+
require_row_format:
195+
description:
196+
- Same as mysql variable.
197+
type: bool
198+
version_added: 1.2.0
199+
require_table_primary_key_check:
200+
description:
201+
- Same as mysql variable.
202+
choices: [stream, on, off]
203+
type: str
204+
version_added: 1.2.0
205+
source_connection_auto_failover:
206+
description:
207+
- Same as mysql variable.
208+
type: bool
209+
version_added: 1.2.0
210+
master_compression_algorithms:
211+
description:
212+
- Same as mysql variable.
213+
type: str
214+
version_added: 1.2.0
215+
master_zstd_compression_level:
216+
description:
217+
- Same as mysql variable.
218+
choices: [1-22]
219+
type: int
220+
version_added: 1.2.0
221+
master_tls_ciphersuites:
222+
description:
223+
- Same as mysql variable.
224+
type: str
225+
version_added: 1.2.0
226+
master_public_key_path:
227+
description:
228+
- Same as mysql variable.
229+
type: str
230+
version_added: 1.2.0
231+
get_master_public_key:
232+
description:
233+
- Same as mysql variable.
234+
type: bool
235+
version_added: 1.2.0
236+
network_namespace:
237+
description:
238+
- Same as mysql variable.
239+
type: str
240+
version_added: 1.2.0
134241
channel:
135242
description:
136243
- Name of replication channel.
@@ -387,11 +494,14 @@ def main():
387494
'getmaster', 'getslave', 'changemaster', 'stopslave',
388495
'startslave', 'resetmaster', 'resetslave', 'resetslaveall']),
389496
master_auto_position=dict(type='bool', default=False),
497+
master_bind=dict(type='str'),
390498
master_host=dict(type='str'),
391499
master_user=dict(type='str'),
392500
master_password=dict(type='str', no_log=True),
393501
master_port=dict(type='int'),
502+
master_heartbeat_period=dict(type='int'),
394503
master_connect_retry=dict(type='int'),
504+
master_retry_count=dict(type='int'),
395505
master_log_file=dict(type='str'),
396506
master_log_pos=dict(type='int'),
397507
relay_log_file=dict(type='str'),
@@ -400,11 +510,28 @@ def main():
400510
master_ssl_ca=dict(type='str'),
401511
master_ssl_capath=dict(type='str'),
402512
master_ssl_cert=dict(type='str'),
513+
master_ssl_crl=dict(type='str'),
514+
master_ssl_crlpath=dict(type='str'),
403515
master_ssl_key=dict(type='str'),
404516
master_ssl_cipher=dict(type='str'),
517+
master_ssl_verify_server_cert=dict(type='bool', default=False),
518+
master_tls_version=dict(type='str'),
519+
master_compression_algorithms=dict(type='str'),
520+
master_zstd_compression_level=dict(type='int', choices=list(range(1, 23))),
521+
master_tls_ciphersuites=dict(type='str'),
522+
master_public_key_path=dict(type='str'),
523+
get_master_public_key=dict(type='bool', default=False),
405524
master_use_gtid=dict(type='str', choices=['current_pos', 'slave_pos', 'disabled']),
525+
ignore_server_ids=dict(type='list'),
526+
do_domain_ids=dict(type='list'),
527+
ignore_domain_ids=dict(type='list'),
406528
master_delay=dict(type='int'),
407529
connection_name=dict(type='str'),
530+
privilege_checks_user=dict(type='str', choices=['account']),
531+
require_row_format=dict(type='bool', default=False),
532+
require_table_primary_key_check=dict(type='str', choices=['stream', 'on', 'off']),
533+
source_connection_auto_failover=dict(type='bool', default=False),
534+
network_namespace=dict(type='str'),
408535
channel=dict(type='str'),
409536
fail_on_error=dict(type='bool', default=False),
410537
)
@@ -415,11 +542,14 @@ def main():
415542
],
416543
)
417544
mode = module.params["mode"]
545+
master_bind = module.params["master_bind"]
418546
master_host = module.params["master_host"]
419547
master_user = module.params["master_user"]
420548
master_password = module.params["master_password"]
421549
master_port = module.params["master_port"]
550+
master_heartbeat_period = module.params["master_heartbeat_period"]
422551
master_connect_retry = module.params["master_connect_retry"]
552+
master_retry_count = module.params["master_retry_count"]
423553
master_log_file = module.params["master_log_file"]
424554
master_log_pos = module.params["master_log_pos"]
425555
relay_log_file = module.params["relay_log_file"]
@@ -428,9 +558,26 @@ def main():
428558
master_ssl_ca = module.params["master_ssl_ca"]
429559
master_ssl_capath = module.params["master_ssl_capath"]
430560
master_ssl_cert = module.params["master_ssl_cert"]
561+
master_ssl_crl = module.params["master_ssl_crl"]
562+
master_ssl_crlpath = module.params["master_ssl_crlpath"]
431563
master_ssl_key = module.params["master_ssl_key"]
432564
master_ssl_cipher = module.params["master_ssl_cipher"]
565+
master_ssl_verify_server_cert = module.params["master_ssl_verify_server_cert"]
566+
master_tls_version = module.params["master_tls_version"]
567+
master_compression_algorithms = module.params["master_compression_algorithms"]
568+
master_zstd_compression_level = module.params["master_zstd_compression_level"]
569+
master_tls_ciphersuites = module.params["master_tls_ciphersuites"]
570+
master_public_key_path = module.params["master_public_key_path"]
571+
get_master_public_key = module.params["get_master_public_key"]
433572
master_auto_position = module.params["master_auto_position"]
573+
ignore_server_ids = module.params["ignore_server_ids"]
574+
do_domain_ids = module.params["do_domain_ids"]
575+
ignore_domain_ids = module.params["ignore_domain_ids"]
576+
privilege_checks_user = module.params["privilege_checks_user"]
577+
require_row_format = module.params["require_row_format"]
578+
require_table_primary_key_check = module.params["require_table_primary_key_check"]
579+
source_connection_auto_failover = module.params["source_connection_auto_failover"]
580+
network_namespace = module.params["network_namespace"]
434581
ssl_cert = module.params["client_cert"]
435582
ssl_key = module.params["client_key"]
436583
ssl_ca = module.params["ca_cert"]
@@ -484,6 +631,8 @@ def main():
484631
elif mode in "changemaster":
485632
chm = []
486633
result = {}
634+
if master_bind is not None:
635+
chm.append("MASTER_BIND='%s'" % master_bind)
487636
if master_host is not None:
488637
chm.append("MASTER_HOST='%s'" % master_host)
489638
if master_user is not None:
@@ -492,8 +641,12 @@ def main():
492641
chm.append("MASTER_PASSWORD='%s'" % master_password)
493642
if master_port is not None:
494643
chm.append("MASTER_PORT=%s" % master_port)
644+
if master_heartbeat_period is not None:
645+
chm.append("MASTER_HEARTBEAT_PERIOD='%s'" % master_heartbeat_period)
495646
if master_connect_retry is not None:
496647
chm.append("MASTER_CONNECT_RETRY=%s" % master_connect_retry)
648+
if master_retry_count is not None:
649+
chm.append("MASTER_RETRY_COUNT='%s'" % master_retry_count)
497650
if master_log_file is not None:
498651
chm.append("MASTER_LOG_FILE='%s'" % master_log_file)
499652
if master_log_pos is not None:
@@ -512,14 +665,48 @@ def main():
512665
chm.append("MASTER_SSL_CAPATH='%s'" % master_ssl_capath)
513666
if master_ssl_cert is not None:
514667
chm.append("MASTER_SSL_CERT='%s'" % master_ssl_cert)
668+
if master_ssl_crl is not None:
669+
chm.append("MASTER_SSL_CRL='%s'" % master_ssl_crl)
670+
if master_ssl_crlpath is not None:
671+
chm.append("MASTER_SSL_CRLPATH='%s'" % master_ssl_crlpath)
515672
if master_ssl_key is not None:
516673
chm.append("MASTER_SSL_KEY='%s'" % master_ssl_key)
517674
if master_ssl_cipher is not None:
518675
chm.append("MASTER_SSL_CIPHER='%s'" % master_ssl_cipher)
676+
if master_ssl_verify_server_cert:
677+
chm.append("MASTER_SSL_VERIFY_SERVER_CERT=1")
678+
if master_tls_version is not None:
679+
chm.append("MASTER_TLS_VERSION='%s'" % master_tls_version)
680+
if master_compression_algorithms is not None:
681+
chm.append("MASTER_COMPRESSION_ALGORITHMS='%s'" % master_compression_algorithms)
682+
if master_zstd_compression_level is not None:
683+
chm.append("MASTER_ZSTD_COMPRESSION_LEVEL='%s'" % master_zstd_compression_level)
684+
if master_tls_ciphersuites is not None:
685+
chm.append("MASTER_TLS_CIPHERSUITES='%s'" % master_tls_ciphersuites)
686+
if master_public_key_path is not None:
687+
chm.append("MASTER_PUBLIC_KEY_PATH='%s'" % master_public_key_path)
688+
if get_master_public_key:
689+
chm.append("GET_MASTER_PUBLIC_KEY=1")
519690
if master_auto_position:
520691
chm.append("MASTER_AUTO_POSITION=1")
521692
if master_use_gtid is not None:
522693
chm.append("MASTER_USE_GTID=%s" % master_use_gtid)
694+
if ignore_server_ids:
695+
chm.append("IGNORE_SERVER_IDS='%s'" % ','.join(ignore_server_ids))
696+
if do_domain_ids:
697+
chm.append("DO_DOMAIN_IDS='%s'" % ','.join(do_domain_ids))
698+
if ignore_domain_ids:
699+
chm.append("IGNORE_DOMAIN_IDS='%s'" % ','.join(ignore_domain_ids))
700+
if privilege_checks_user is not None:
701+
chm.append("PRIVILEGE_CHECKS_USER='%s'" % privilege_checks_user)
702+
if require_row_format:
703+
chm.append("REQUIRE_ROW_FORMAT=1")
704+
if require_table_primary_key_check is not None:
705+
chm.append("REQUIRE_TABLE_PRIMARY_KEY_CHECK='%s'" % require_table_primary_key_check)
706+
if source_connection_auto_failover:
707+
chm.append("SOURCE_CONNECTION_AUTO_FAILOVER=1")
708+
if network_namespace is not None:
709+
chm.append("NETWORK_NAMESPACE='%s'" % network_namespace)
523710
try:
524711
changemaster(cursor, chm, connection_name, channel)
525712
except mysql_driver.Warning as e:

0 commit comments

Comments
 (0)