generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 89
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_query returns changed: true when nothing is executed. #268
Comments
Andersson007
changed the title
mysql_user returns changed: true when nothing is executed.
mysql_query returns changed: true when nothing is executed.
Mar 15, 2022
@itcultus hi, thanks for reporting this! Sorry for the late reply - missed the issue somehow. Would you like to pick it up? If we can catch the warning and parse, we could add a corresponding action, ie. if already exists in warning: changed = False or something |
@itcultus the PR has just been merged, with PyMySQL it should work correctly, thanks! |
This was referenced Jun 2, 2022
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SUMMARY
I used the mysql_query with some "CREATE TABLE IF NOT EXISTS" statements.
The second time I run the query, it reports "changed" although nothing is executed since the tables are already created. The
mysql_query
module has the "changed: true" hardcoded in the return values simply by looking if some keywords are present. However, as you can see it's a bit more complex than that.Let's see this SQL query:
If we execute this statement in the mysql/mariadb CLI client, we will see this:
The warning of course is that the table already exists.
When I execute the statement for a table that doesn't exist, we see this:
We have no warnings, the query IS OK, so, we can safely assume that the table is created.
I don't know if you have discussed it in the past, but in my opinion the code should be a bit more selective on when to return "Changed" and when not. I classify this as a bug, but obviously if you feel that it's a feature request, I am more than fine with it.
ISSUE TYPE
COMPONENT NAME
mysql_query
ANSIBLE VERSION
COLLECTION VERSION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
Module should return OK when no action is taken from the DB server when we execute DDL statements.
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: