-
Notifications
You must be signed in to change notification settings - Fork 93
mysql_user - added queries to module output and set no_log option on … #92
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_user - added queries to module output and set no_log option on … #92
Conversation
…plugin_hash_string and plugin_auth_string (ansible-collections#75)
Codecov Report
@@ Coverage Diff @@
## main #92 +/- ##
==========================================
- Coverage 75.07% 74.67% -0.41%
==========================================
Files 12 12
Lines 1645 1674 +29
Branches 423 425 +2
==========================================
+ Hits 1235 1250 +15
- Misses 267 280 +13
- Partials 143 144 +1
Continue to review full report at Codecov.
|
Looks like mysqlclient doesn't have a
I'll have to take a look at what the other options are. It seems like in other areas of the project the cursor private variables are being used which isn't ideal. In others, it seems to be simple string replacement which from my understanding won't work for all cases. |
I created an issue for the mysqlclient project to see if adding mogrify would be considered: PyMySQL/mysqlclient#476 That seems like one of the better solutions that I can think of at the moment. The worst-case could be to only log the queries output if the MySQL connector in use supports |
I have a PR up for review for the mysqlclient change. Even when that is implemented it will only work for the latest version when released, so I'm thinking that I'll still check the cursor for |
RETURN = '''#''' | ||
RETURN = r''' | ||
queries: | ||
description: List of executed queries which modified DB's state. |
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.
description: List of executed queries which modified DB's state. | |
description: List of executed queries which modified a state of a database. |
We shouldn't use abbreviations if possible
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 copied that from mysql_replication.py
for consistency, but agree that it could be better. I'll fix it.
@steveteahan thanks for working on this!
Just a suggestion, I don't feel fresh now:) Also the codecov-related tests should be green. |
BTW i don't see a good explanation in the module's documentation of what |
Co-authored-by: Andrew Klychkov <[email protected]>
Moving away from a warning seems reasonable to me if your experience in the community has been that it is more of annoyance than doing any good. I can do something like what is suggested, but maybe leave the appending to
One of the issues is not testing MySQL 5.6 which I tried to start a discussion about in #91. The other part was never covered, but I'll try to get a test together for it.
|
@@ -592,11 +633,15 @@ def user_mod(cursor, user, host, host_all, password, encrypted, | |||
if module.check_mode: | |||
return (True, msg) | |||
if old_user_mgmt: | |||
cursor.execute("SET PASSWORD FOR %s@%s = %s", (user, host, encrypted_password)) | |||
query = "SET PASSWORD FOR %s@%s = %s" |
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.
This is the example of the missing coverage for MySQL 5.6 that I mentioned above.
I did a bit of research and enabling integration tests for MySQL 5.6 is not going to be trivial (see #91). old_user_mgmt
handles cases where MariaDB < 10.2 and MySQL < 5.7. The only version in that set that is still supported is MySQL 5.6 (for another two weeks). I don't see it being worthwhile spending any time on this. As per the discussion is #91 it might be worthwhile to consider dropping this support and removing the code in the near future.
Unless there are other suggestions, I can go ahead and remove this change. The downside is that until we remove MariaDB < 10.2 and MySQL < 5.7 code paths, there will be queries that can modify the database state, but will not be logged via the module.
I meant it'll be append once, then will be skipped. But feel free to implement that as you like, will see
If so, sounds sensible |
The Thanks! |
@Andersson007 @steveteahan The codebase has changed dramatically since opening this PR. At this point I don't know if rebasing is going to be any easier than replicating the work on top of the current head. |
Agreed |
Closing this PR based on the feedback above. |
@steveteahan thank you! |
…plugin_hash_string and plugin_auth_string (#75)
SUMMARY
Fixes #75
ISSUE TYPE
COMPONENT NAME
mysql_user
ADDITIONAL INFORMATION
user_mod
I skipped adding the queries in an exception case because it currently doesn't have test coverage and I couldn't reproduce the issue in either MySQL 5.7 or 8.0. The code in question is here: https://github.com/ansible-collections/community.mysql/blob/main/plugins/modules/mysql_user.py#L601