-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
mysql_replication: add connection_name param for MariaDB multi source replication support #63229
Merged
felixfontein
merged 2 commits into
ansible:devel
from
Andersson007:mariadb_connection_name
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/63229-mysql_replication_add_connection_name_parameter.yml
This file contains 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 ``connection_name`` parameter (https://github.com/ansible/ansible/issues/46243). |
This file contains 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 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 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
118 changes: 118 additions & 0 deletions
118
test/integration/targets/mariadb_replication/tasks/mariadb_replication_connection_name.yml
This file contains 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,118 @@ | ||
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
# Needs for further tests: | ||
- name: Stop slave | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: stopslave | ||
|
||
- name: Reset slave all | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: resetslaveall | ||
|
||
# Get master log pos: | ||
- name: Get master status | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ master_port }}" | ||
mode: getmaster | ||
register: master_status | ||
|
||
# Test changemaster mode: | ||
- name: Run replication with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: changemaster | ||
master_host: 127.0.0.1 | ||
master_port: "{{ master_port }}" | ||
master_user: "{{ replication_user }}" | ||
master_password: "{{ replication_pass }}" | ||
master_log_file: mysql-bin.000001 | ||
master_log_pos: '{{ master_status.Position }}' | ||
connection_name: '{{ conn_name }}' | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is changed | ||
- result.queries == ["CHANGE MASTER '{{ conn_name }}' TO MASTER_HOST='127.0.0.1',MASTER_USER='replication_user',MASTER_PASSWORD='********',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=765"] | ||
|
||
# Test startslave mode: | ||
- name: Start slave with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: startslave | ||
connection_name: "{{ conn_name }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is changed | ||
- result.queries == ["START SLAVE \'{{ conn_name }}\'"] | ||
|
||
# Test getslave mode: | ||
- name: Get standby statu with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: getslave | ||
connection_name: "{{ conn_name }}" | ||
register: slave_status | ||
|
||
- assert: | ||
that: | ||
- slave_status.Is_Slave == true | ||
- slave_status.Master_Host == '127.0.0.1' | ||
- slave_status.Exec_Master_Log_Pos == master_status.Position | ||
- slave_status.Master_Port == {{ master_port }} | ||
- slave_status.Last_IO_Errno == 0 | ||
- slave_status.Last_IO_Error == '' | ||
- slave_status is not changed | ||
|
||
# Test stopslave mode: | ||
- name: Stop slave with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: stopslave | ||
connection_name: "{{ conn_name }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is changed | ||
- result.queries == ["STOP SLAVE \'{{ conn_name }}\'"] | ||
|
||
# Test reset | ||
- name: Reset slave with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: resetslave | ||
connection_name: "{{ conn_name }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is changed | ||
- result.queries == ["RESET SLAVE \'{{ conn_name }}\'"] | ||
|
||
# Test reset all | ||
- name: Reset slave all with connection_name | ||
mysql_replication: | ||
login_host: 127.0.0.1 | ||
login_port: "{{ standby_port }}" | ||
mode: resetslaveall | ||
connection_name: "{{ conn_name }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is changed | ||
- result.queries == ["RESET SLAVE \'{{ conn_name }}\' ALL"] |
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.
Does this need any proper escaping?
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.
@felixfontein i didn't get an idea, could you please describe this? (it's covered by ci:)
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.
If
connection_name
is'; DROP TABLE ORDERS; --
this will have unintended side-effects. (https://www.xkcd.com/327/)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.
@felixfontein shouldn't we trust the argument ?
I mean, these features aren't ment to used with arguments coming from untrusted sources I guess, or should be escaped / protected earlier in the code.
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.
And, as far as I remember,
cursor.execute
won't execute a multi statement query, so the injection should fail.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.
if a user wants to drop his production databases, i believe, it is unavoidable
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.
Most security holes come from such assumptions, which get forgotten over time :) If you want to merge it this way, fine for me. Just don't complain nobody told you ;)