mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-23 05:10:24 -07:00
Refactor the way server_id is set for replicas
The simple way is to add '--server-id 2' after the name of the image of the container. But GHA doesn't let us do that. The idea of mount a file from our repo doesn't work because the repo is check out later in the workflow and I failed to find a pre-job hook. Then I realized that this MySQL option is dynamic! So we will set that in the test target!
This commit is contained in:
parent
163a43ba80
commit
8d43f9e573
5 changed files with 17 additions and 18 deletions
|
@ -1,4 +0,0 @@
|
|||
[mysqld]
|
||||
skip-host-cache
|
||||
skip-name-resolve
|
||||
server_id = 2
|
|
@ -1,4 +0,0 @@
|
|||
[mysqld]
|
||||
skip-host-cache
|
||||
skip-name-resolve
|
||||
server_id = 3
|
|
@ -26,13 +26,28 @@
|
|||
- db_engine == 'mysql'
|
||||
- db_version is version('8.0.22', '>=')
|
||||
|
||||
# We can't pass --server-id to service containers in GHA
|
||||
- name: Change replica1 server_id to 2
|
||||
mysql_variables:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica1_port }}'
|
||||
variable: server_id
|
||||
value: 2
|
||||
|
||||
- name: Change replica2 server_id to 3
|
||||
mysql_variables:
|
||||
<<: *mysql_params
|
||||
login_port: '{{ mysql_replica2_port }}'
|
||||
variable: server_id
|
||||
value: 3
|
||||
|
||||
# Preparation:
|
||||
- name: Create user for mysql replication
|
||||
shell: "echo \"CREATE USER '{{ replication_user }}'@'{{ gateway_addr }}' IDENTIFIED WITH mysql_native_password BY '{{ replication_pass }}'; GRANT REPLICATION SLAVE ON *.* TO '{{ replication_user }}'@'{{ gateway_addr }}';\" | {{ mysql_command }}"
|
||||
shell: "echo \"CREATE USER '{{ replication_user }}'@'{{ mysql_host }}' IDENTIFIED WITH mysql_native_password BY '{{ replication_pass }}'; GRANT REPLICATION SLAVE ON *.* TO '{{ replication_user }}'@'{{ mysql_host }}';\" | {{ mysql_command }}"
|
||||
when: db_engine == 'mysql'
|
||||
|
||||
- name: Create user for mariadb replication
|
||||
shell: "echo \"CREATE USER '{{ replication_user }}'@'{{ gateway_addr }}' IDENTIFIED BY '{{ replication_pass }}'; GRANT REPLICATION SLAVE ON *.* TO '{{ replication_user }}'@'{{ gateway_addr }}';\" | {{ mysql_command }}"
|
||||
shell: "echo \"CREATE USER '{{ replication_user }}'@'{{ mysql_host }}' IDENTIFIED BY '{{ replication_pass }}'; GRANT REPLICATION SLAVE ON *.* TO '{{ replication_user }}'@'{{ mysql_host }}';\" | {{ mysql_command }}"
|
||||
when: db_engine == 'mariadb'
|
||||
|
||||
- name: Create test database
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue