Skip to content
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

[CP4BA] Cleaning PostgreSQL scripts #835

Merged
merged 9 commits into from
Dec 3, 2024

Conversation

P-147
Copy link
Contributor

@P-147 P-147 commented Nov 13, 2024

Hello again cpd team!

As I was working on PR #826 , I noticed a lot of possible improvements in the scripts creating the Postgres DB.
Here are my submissions ; I think this should improve the global readability of the ansible scripts.

I also have a question about a part of the scripts, cf. to this other question at end of this PR description.

TL;DR

This patch fix multiple discrepancies between some identical pg SQL snippets, some incoherence/useless code and simplify the global readability of those scrips (in my opinion — Feel free to debate with me on this! 😄 )

List of Changes

  • 57d7142 : Remove a duplicated ansible script for creating the DB proj2 for ADP
  • 972a60a : Replace all SQLCREATE ROLE with the simpler CREATE USER that has better intent on the expected usage for this ROLE
  • b1c47da : Remove some unnecessary GRANT as the database/tablespace OWNERs already have those permission
  • f992230 : Fix some CREATE TABLESPACE not used during database creation
  • 8d706c2 : Normalize other database scripts using default tablespace
  • bf4b9dc : Remove unnecessary AUTHORIZATION for basdb users owning the created schema
  • 10edbf7 : Revoke all connection rights on databases for public users.
  • 6cc0884 : (NEW) Modify tablespace folder names and associated create/delete roles to improve readability

I'm waiting for your feedback! 😄

proj2 database is already created in previous ansible task `ADP proj DBs`

Signed-off-by: Pierre DANIEL <[email protected]>
Replace `CREATE ROLE` syntax with its equivalent USER syntax with clearer intent.

Signed-off-by: Pierre DANIEL <[email protected]>
Remove some unnecessary commands like `GRANT ...` for database/tablespace OWNERs, as they already have those permissions.

Signed-off-by: Pierre DANIEL <[email protected]>
Some `CREATE TABLESPACE` commands are declared after and/or forgotten in the `CREATE DATABASE` command.

Databases that didn't already declare a tablespace will continue to use the default tablespace `pg_default`

Signed-off-by: Pierre DANIEL <[email protected]>
Fix other `CREATE DATABASE` commands using the `pg_default` tablespace

Signed-off-by: Pierre DANIEL <[email protected]>
Remove the `AUTHORIZATION` as the schema is already owned by the basdb `USER` creating it.

Signed-off-by: Pierre DANIEL <[email protected]>
Remove `CONNECT` priviledges for all `PUBLIC` accounts on databases.
This prevents any `USER`s outside the db ower and database superuser to use the db.

Signed-off-by: Pierre DANIEL <[email protected]>
@P-147 P-147 force-pushed the cp4ba-clean-pg-scripts branch from 719097c to 10edbf7 Compare November 13, 2024 01:57
@jandusek4 jandusek4 self-requested a review November 15, 2024 08:15
@P-147 P-147 changed the base branch from main to cp4ba20241128 November 29, 2024 12:52
@fketelaars fketelaars marked this pull request as draft December 2, 2024 07:27
- Remove "_tbs" suffix from ansible tasklist `remove-postgresql-tablespace.yml` for better variable meaning `common_postgresql_tablespace_name` (and not database name)
- Add  "_tbs" suffix back to the "with_items" list used by the removal role to index tablespaces
- To normalize tablespaces naming on filesystem and folder removal, "_tbs" suffix is also added in tablespace folder location

Signed-off-by: Pierre DANIEL <[email protected]>
@P-147 P-147 marked this pull request as ready for review December 3, 2024 00:45
Fix naming in ansible task responsible for tablespace folder creation.

Signed-off-by: Pierre DANIEL <[email protected]>
@jandusek4 jandusek4 merged commit 362446d into IBM:cp4ba20241128 Dec 3, 2024
2 checks passed
@P-147 P-147 deleted the cp4ba-clean-pg-scripts branch December 3, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants