Skip to content

re-setting of privileges each puppet run after adding privileges for another database to puppet controlled user #1543

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
o4ier opened this issue Mar 15, 2023 · 5 comments

Comments

@o4ier
Copy link

o4ier commented Mar 15, 2023

Describe the Bug

Creating a new, additional database on mysqlserver (by hand) and granting puppet controlled user privileges on it causes setting of privileges on each puppet run, because the set privileges are not evaluated correctly

Expected Behavior

granting a puppet controlled user privileges on another databases should not cause endless re-setting of privileges for that user

Steps to Reproduce

Steps to reproduce the behavior:

  1. create a database (eg. database1) with this module
  2. create a user (eg. user1) with this module
  3. grant user1 privileges (eg. 'ALL') on database1 with this module
  4. run puppet multiple times -> no more changes after initial set up
  5. create a new database (eg. database2) by hand on the system
  6. grant user1 privileges (eg. 'ALL') on database2
  7. run puppet (multiple times) -> each puppet run changes the privileges for user1@database1

Environment

  • Version 1.13.2.0
  • Platform RHEL 8 and 9

Additional Context

I still have another issue ( #1502 ) /pr ( #1503 ) open/existing, which somehow got lost on my desk.
Can I reopen the pr and use it to fix both issues?
Or should I create a new pr for this issue, after the first one is accepted after i fixed it?

@o4ier
Copy link
Author

o4ier commented Mar 15, 2023

@fetzerms
Copy link

fetzerms commented Apr 24, 2023

@o4ier did you find out why this behaves differently on "externally" created databases? We encountered the same issue in some RHEL7->RHEL8 migrated database, while it works on others.

Update: Running mysql_upgrade fixed the issue for "old" databases.

@o4ier
Copy link
Author

o4ier commented Apr 24, 2023

@fetzerms The problem was that when "show grants" for a specific user produces output with more than one row, only the last row was evaluated by the module.
So puppet always thinks "user1 has no grants on database1" and sets them each time.

In our use case the first row is the database managed by puppet, as we don't support automatic installations with multiple users/databases. But we cannot prevent that somebody else creates new databases and grants.

I don't know how the "mysql way" of doing such things is in theory (like "a new user for each database"), but in practice it happens that one user has grants on multiple databases.

Maybe the ordering of grants output in your setup was not strictly "puppet controlled first", so puppet evaluated the correct row by chance on some systems, as it was the last one.

@daylicron
Copy link

Hi @o4ier ,
thanks for your work so far, we're hitting the same issue. Do you might have some time to open a PR for this? We would really appretiate this. 👍

@o4ier
Copy link
Author

o4ier commented Jan 21, 2024

@daylicron as the changes made in my fix are dependent on a "broken" PR, I am currently not able to integrate my changes into the current main-Codebase, which looks very different than the state it was in when I wrote my fix.

But feel free to fork, add my changes, and open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants