generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 102
Add options to start and stop group replication #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eryx12o45
wants to merge
13
commits into
ansible-collections:main
Choose a base branch
from
eryx12o45:add_group_replication_option_to_mysql_replication_module
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
35122ce
Add options to start and stop group replication
eryx12o45 6f686aa
Added test
eryx12o45 a2dff5c
fix liniting
eryx12o45 1a7b06b
fix missing mysql def in script
eryx12o45 7c37659
fix more tests
eryx12o45 461efe6
fix more tests
eryx12o45 1439274
fix more tests
eryx12o45 781bf60
adding missing mysql group_replication module
eryx12o45 54b4eff
fix 'fail' tests
eryx12o45 81045d0
fix missing Warning attr. on MockCursor
eryx12o45 4b14ac1
fix linting
eryx12o45 12a95c4
fix warning baseexception class error
eryx12o45 9e90a23
fix version strings
eryx12o45 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/mysql_replication_add_group_replication_commands.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| minor_changes: | ||
| - mysql_replication - add ``startgroupreplication`` and ``stopgroupreplication`` options (https://github.com/ansible-collections/community.mysql/pull/647). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
tests/integration/targets/test_mysql_replication/tasks/mysql_replication_group.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| # Copyright: (c) 2025, Sebastian Pfahl (@eryx12o45) | ||
| # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
|
||
| - vars: | ||
| mysql_params: &mysql_params | ||
| login_user: '{{ mysql_user }}' | ||
| login_password: '{{ mysql_password }}' | ||
| login_host: '{{ mysql_host }}' | ||
|
|
||
| block: | ||
| # Setup group replication prerequisites | ||
| - name: Create group replication user | ||
| shell: | ||
| "echo \"CREATE USER IF NOT EXISTS \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}' \ | ||
| IDENTIFIED {% if db_engine == 'mysql' %}WITH mysql_native_password {% endif %}BY '{{ group_replication_pass }}'; \ | ||
| GRANT REPLICATION SLAVE ON *.* TO \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}'; \ | ||
| GRANT CONNECTION_ADMIN ON *.* TO \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}'; \ | ||
| GRANT BACKUP_ADMIN ON *.* TO \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}'; \ | ||
| GRANT GROUP_REPLICATION_STREAM ON *.* TO \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}'; \ | ||
| FLUSH PRIVILEGES;\" | {{ mysql_command }}" | ||
| when: db_engine == 'mysql' and db_version is version('8.0.0', '>=') | ||
|
|
||
| - name: Create group replication user for MariaDB | ||
| shell: | ||
| "echo \"CREATE USER IF NOT EXISTS \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}' \ | ||
| IDENTIFIED BY '{{ group_replication_pass }}'; \ | ||
| GRANT REPLICATION SLAVE ON *.* TO \ | ||
| '{{ group_replication_user }}'@'{{ mysql_host }}';\" | {{ mysql_command }}" | ||
| when: db_engine == 'mariadb' | ||
|
|
||
| # Configure group replication settings | ||
| - name: Configure group replication settings for MySQL | ||
| shell: | ||
| "echo \"INSTALL PLUGIN group_replication SONAME 'group_replication.so'; \ | ||
| SET GLOBAL group_replication_group_name='{{ group_replication_group_name }}'; \ | ||
| SET GLOBAL group_replication_local_address='{{ mysql_host }}:{{ group_replication_port }}'; \ | ||
| SET GLOBAL group_replication_group_seeds='{{ mysql_host }}:{{ group_replication_port }}'; \ | ||
| SET GLOBAL group_replication_bootstrap_group=ON;\" | {{ mysql_command }}" | ||
| when: db_engine == 'mysql' and db_version is version('8.0.0', '>=') | ||
|
|
||
| - name: Configure group replication settings for MariaDB | ||
| shell: | ||
| "echo \"SET GLOBAL wsrep_provider='/usr/lib/galera/libgalera_smm.so'; \ | ||
| SET GLOBAL wsrep_cluster_name='{{ group_replication_group_name }}'; \ | ||
| SET GLOBAL wsrep_cluster_address='gcomm://{{ mysql_host }}:{{ group_replication_port }}'; \ | ||
| SET GLOBAL wsrep_node_address='{{ mysql_host }}:{{ group_replication_port }}';\" | {{ mysql_command }}" | ||
| when: db_engine == 'mariadb' and db_version is version('10.1.0', '>=') | ||
| ignore_errors: true | ||
|
|
||
| # Test startgroupreplication mode | ||
| - name: Start group replication | ||
| mysql_replication: | ||
| <<: *mysql_params | ||
| mode: startgroupreplication | ||
| group_replication_user: '{{ group_replication_user }}' | ||
| group_replication_password: '{{ group_replication_pass }}' | ||
| register: result | ||
| ignore_errors: true | ||
|
|
||
| - name: Assert that startgroupreplication returns expected values | ||
| assert: | ||
| that: | ||
| - result is changed | ||
| - result.queries | length > 0 | ||
| - "'START GROUP_REPLICATION' in result.queries[0]" | ||
| when: result is not failed | ||
|
|
||
| # Check group replication status | ||
| - name: Check group replication status | ||
| shell: | ||
| "echo \"SHOW STATUS LIKE 'group_replication_status';\" | {{ mysql_command }}" | ||
| register: gr_status | ||
| ignore_errors: true | ||
|
|
||
| # Test stopgroupreplication mode | ||
| - name: Stop group replication | ||
| mysql_replication: | ||
| <<: *mysql_params | ||
| mode: stopgroupreplication | ||
| register: result | ||
| ignore_errors: true | ||
|
|
||
| - name: Assert that stopgroupreplication returns expected values | ||
| assert: | ||
| that: | ||
| - result is changed | ||
| - result.queries | length > 0 | ||
| - "'STOP GROUP_REPLICATION' in result.queries[0]" | ||
| when: result is not failed | ||
|
|
||
| # Cleanup group replication settings | ||
| - name: Reset group replication settings for MySQL | ||
| shell: | ||
| "echo \"SET GLOBAL group_replication_bootstrap_group=OFF;\" | {{ mysql_command }}" | ||
| when: db_engine == 'mysql' and db_version is version('8.0.0', '>=') | ||
| ignore_errors: true | ||
|
|
||
| - name: Drop group replication user | ||
| shell: | ||
| "echo \"DROP USER IF EXISTS '{{ group_replication_user }}'@'{{ mysql_host }}';\" | {{ mysql_command }}" | ||
| ignore_errors: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see many ignore_erros + this condition. The thing is that we can't be sure our test work.
can we handle it somehow w/o using ignore_errors + run if not failed ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eryx12o45 ^ (besides the above, LGTM)