Postgres Grant State and Module needed.
Howdy,
It would be real handy to have a Postgres grant module and state much like MySQL does.
To do this currently, you need to either use scripts or gasp by hand.
Thanks Jason Swindle
Sounds great! Thanks for the suggestion!
+1
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:
- should/can this module be based on the
mysql_grantsstate? - the
mysql_grantsstate usesmysql.grant_exists, defined in themysqlmodule - a similar method must be added to thepostgresmodule, correct? - since these states would share so much code, would it make sense to build a generic
relational_databasestate and have them inherit from that? This would make common bugfixes easier, and also state usage for databases. We'd have a state definition withdbmsas a required parameter, making it easy to switch frommysqltopostgresat any time.
I welcome any feedback :)
Best regards,
Can we get an update on this? Maybe get this into Hydrogen?
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.
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.
Sorry, here's my input:
- 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.
- Correct. (Assuming that makes sense -- see (1))
- 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.utilsmodule with those helper methods for DRY.
@tomeduarte Ping :)
@tomeduarte Ping Ping... :)
@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.
+1
I think this issue should be closed, postgres modules are here and have been for a while.
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.