-
Notifications
You must be signed in to change notification settings - Fork 88
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: Granting all privileges at a global level always results in a change in MySQL 8.0 #77
Comments
This is not my area too. I'm against hard-coding (who will maintain this?),
|
I faced the same issue. Idempotence test fails on the following task: - name: Update mysql root password for all root accounts
mysql_user:
name: root
host_all: true
password: '{{ mysql_root_password }}'
check_implicit_admin: true
priv: '*.*:ALL,GRANT'
login_user: '{{ mysql_root_username }}'
login_password: '{{ mysql_root_password }}' |
Same problem here. Someone knows if the fix for this issue is in the roadmap? I tried to define specific global privileges (static, dynamic) to bypass this ALL PRIVILEGES <-> "list of specific privileges" translation problem, but I've seen that there's a list of hard-coded VALID_PRIVS which doesn't contain all privileges. |
Not in mine unfortunately (at least in the nearest future) but I'd be happy to review things if someone picks it up and submits a fix. I'm thinking of determining the list of possible privileges dynamically (i.e. to fetch them from a server) instead of having the hardcoded ones. Though not sure if it's possible. If anyone shares the SQL query that works on all supported versions, it would be great (if exists). |
Though it can be painful to implement OR can lead to breaking changes introduction which i'd generally like to avoid but this frozenset is a really annoying thing. |
@rsicart , can this issue get closed? |
If I understood the PR correctly, the actual modification checks weren't updated, so I'd say the behaviour remains unchanged |
Closed that one, thanks for pointing out! |
I don't know if mysql change it's behavior since the report of this issue but for me it me it was more than a "always results in a change". I use the module to set the root@localhost user privileges. root@localhost is also the user I use to connect to mysql. But from what I understand, because of the diff between ['ALL', 'GRANT'] and [ So now my root@localhost is useless, and I don't have any other user with the GRANT privilege… so I am "locked out" of my mysql. What I suggest : if 'ALL' is in |
@Andersson007 let's prioritize this, @tchernomax issue is quite serious. |
@tchernomax thanks for reporting this!
@Jorge-Rodriguez agreed! Would you like to pick it up? |
I can have a stab at it yes. Although another pair of eyes couldn't hurt. |
Cool, thanks a lot! |
I've bumped into this bug using MySQL 8. I have a play updating the root password and ensuring the privileges are correct using
I have plays later on trying to create users and grant permissions to databases however, this wasn't working regardless of what priv vars I tried. After finding this issue I did find the grant option was being removed from the root user in the exact same manner as described above. Checking MySQL the Grant permission is removed:
I did still have all other permissions as the root user so I was able to add grant back to root using an SQL update query and confirm the permission was effectively restored. @tchernomax the update query below will get you up and running again if you did get stuck where no users have the grant priv.
After running my playbook again, the grant permission was removed from the root user.
This is happening with all users where ALL,GRANT is defined. The only workaround I can use for now will be the good old fall back to the shell module and executing commands outside the mysql_user module until resolved. Regards, |
Just clarify that the Grant Priv revocation problem seems to be present in collection 3.4.1, but not in 2.3.8. Problem is not present when creating new users (user_add only grants privs), but present on user modification, where grants and revokes are done. |
@tchernomax update mysql.global_priv set Priv='{"access": 18446744073709551615, "authentication_string": "censored","version_id":100609,"plugin":"mysql_native_password"}' where User='root' and Host='localhost'; Then stop and start normally. |
@rsicart should the issue get closed? (i've released the collection version that contains your fix) |
No, at the moment we always have a change. As @tchernomax commented, we should try to make a diff of privileges before and after configuring privileges. Perhaps something similar to a deep diff of dicts. |
@rsicart ah, ok, thanks for clarifying! |
Thanks everyone involved! UPDATE: it's not in the release, i mixed it up with another fix, i apologize |
Hum, I'm a little bit late for that, but the issue doesn't seem entirely fixed. If I run ansible with I'm running Should we reopen this issue or should I open a new one? |
@pgrenaud hello, thanks for reporting the case! |
@rsicart do you have time to take a look? ^ |
Hey @Andersson007, thanks for letting me know. I'm a little busy lately, I prefer that someone takes a look (if possible). |
@rsicart hey, thanks for letting us know! |
SUMMARY
Granting ALL PRIVILEGES at a global level will always result in a change being detected. I came across this issue when trying to re-enable the
user_password_update_test.yml
test for another change. This appears to be linked to the following change in MySQL 8.0:So, because the expanded list of all privileges doesn't match "ALL PRIVILEGES", a change will always be made when applying
*.*:ALL
. Privileges at the database and/or table level are unaffected (hopefully the more common use case).This issue appears to be complicated by the fact that dynamic privileges are defined at runtime as per the docs. This isn't my area of expertise, but my understanding of the implication of this is that we cannot reliably hard-code dynamic privileges to check.
SHOW PRIVILEGES
seems to get us the list of privileges that would be applied to a user with*.*:ALL
(in addition toGRANT
,PROXY
, andUSAGE
).I can think of a couple of options:
SHOW PRIVILEGES
when priv is*.*:ALL
Like I mentioned, this isn't my area of expertise, so it is possible that hard-coding the privileges will really work, but purely based on the documentation it seems like it wouldn't.
ISSUE TYPE
COMPONENT NAME
mysql_user
ANSIBLE VERSION
Development
CONFIGURATION
Development environment
OS / ENVIRONMENT
Development environment
STEPS TO REPRODUCE
The following test will fail and reproduce the issue:
EXPECTED RESULTS
The test above should pass because no change was made to the privileges.
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: