salt icon indicating copy to clipboard operation
salt copied to clipboard

Postgres Grant State and Module needed.

Open JasonSwindle opened this issue 13 years ago • 13 comments

Howdy,

It would be real handy to have a Postgres grant module and state much like MySQL does.

MySQL Grant Doc Link

To do this currently, you need to either use scripts or gasp by hand.

Thanks Jason Swindle

JasonSwindle avatar Aug 07 '13 21:08 JasonSwindle

Sounds great! Thanks for the suggestion!

basepi avatar Aug 07 '13 21:08 basepi

+1

UtahDave avatar Aug 08 '13 00:08 UtahDave

Hello all,

I'm willing to try and build a postgres_grants state, though probably only in a few weeks.

However, it'd be great if we could clarify and discuss some approach details:

  1. should/can this module be based on the mysql_grants state?
  2. the mysql_grants state uses mysql.grant_exists, defined in the mysql module - a similar method must be added to the postgres module, correct?
  3. since these states would share so much code, would it make sense to build a generic relational_database state and have them inherit from that? This would make common bugfixes easier, and also state usage for databases. We'd have a state definition with dbms as a required parameter, making it easy to switch from mysql to postgres at any time.

I welcome any feedback :)

Best regards,

tomeduarte avatar Aug 21 '13 10:08 tomeduarte

Can we get an update on this? Maybe get this into Hydrogen?

JasonSwindle avatar Dec 03 '13 16:12 JasonSwindle

At this point, it's not looking like this will get into Hydrogen, unless a community member is willing to step up. All of our in-company resources are currently working to improve testing and prepare existing features for the release candidate for Hydrogen which we hope to get out in the next week or two.

basepi avatar Dec 03 '13 23:12 basepi

As I said before, I'm willing to step up. I do need, however, your (or someone else's) input on my previous questions as this is a codebase I am not familiar with and am unsure of the best way to proceed.

tomeduarte avatar Dec 03 '13 23:12 tomeduarte

Sorry, here's my input:

  1. I don't know enough about the grants in Postgres vs MySQL to know if these modules should look exactly the same. Assuming the systems are similar enough, I would say we would want to keep them as close to each other as possible.
  2. Correct. (Assuming that makes sense -- see (1))
  3. I don't think we want to add any actual classes or inheritance, but if there is shared code (shared helper methods, etc), you're welcome to create a new salt.utils module with those helper methods for DRY.

basepi avatar Dec 04 '13 18:12 basepi

@tomeduarte Ping :)

JasonSwindle avatar Dec 29 '13 21:12 JasonSwindle

@tomeduarte Ping Ping... :)

JasonSwindle avatar Feb 09 '14 01:02 JasonSwindle

@basepi, @tomeduarte : I know pretty well postgreSQL and MySQL. I made some rewrites on mysql's grants in salt, so now they do what they say they do :-)

PostgreSQL grants are more complex. For sure. http://www.postgresql.org/docs/9.3/static/sql-grant.html

First, in postgres you have for database objects, and grants of roles to roles. Then objects grants covers more than the database and tables, (table, column, view, foreign table, sequence, database, foreign-data wrapper, foreign server, function, procedural language, schema, or tablespace). But at least there's no need to care about the '%' or '_' characters in grant queries like in MySQL.

Talking about grants in postgresql, default privileges should certainly be managed in a postgres state: http://www.postgresql.org/docs/9.3/static/sql-alterdefaultprivileges.html This defines grants for not-yet-created objects. And theses grants are very complex, they are affected to a role, and they will be applied only for objects created by this role.

There's no such things in MySQL, so at the end the only thing you can do is try to have a common subset of shared methods on both states, but each module will certainly also have specific methods. And even on theses shared methods they will not allow the same parameters values (no GRANT TRUNCATE on MySQL).

Using the same methods in postgres and mysql states would help making a dbms module, for sure, but transparent migraton from mysql to postgres is a dream. They usually behave differently. I think if you start to write this state you should try to use the same methods, but writing a shared dbms module is less important than having working states covering all needs for each database.

\cc @kiorky.

regilero avatar Feb 10 '14 08:02 regilero

+1

alienzrcoming avatar May 23 '14 16:05 alienzrcoming

I think this issue should be closed, postgres modules are here and have been for a while.

jdelic avatar Sep 24 '16 19:09 jdelic

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jul 06 '18 19:07 stale[bot]