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

Feature Request: Config template and merge #696

Open
ozum opened this issue Jan 16, 2023 · 2 comments
Open

Feature Request: Config template and merge #696

ozum opened this issue Jan 16, 2023 · 2 comments

Comments

@ozum
Copy link

ozum commented Jan 16, 2023

Hi,

For each new server, I have to edit pg_hba.conf and postgresql.conf and add very similar entries. Is it possible to add a feature to the app to store config templates and apply them to configurations?

IMHO, templates would be more viable than copying configurations, because different PostgreSQL Server versions may have different options and default values in the future.

For example, PostgresApp may store config template entries as key-value pairs and whether they should be overridden.

{
  postgres.conf: {
    listen_addresses: { value: "*", overwrite: true },
    max_connections: { value: 100, overwrite: false}
  },
  // For `pg_hba.conf`, if overwrite is true it erases all entries, otherwise, just add entries above the current ones.
  pg_hba.conf: {
    overwrite: true,
    value: [
	  "local   replication     all                                     trust",
      "host    replication     all             127.0.0.1/32            trust",
      "host    replication     all             ::1/128                 trust",
    ]
}
@tbussmann
Copy link
Member

While there isn't currently a customisable templating mechanism in Postgres.app, you may already alter the defaults used to initialise new clusters per PostgreSQL version within Postgres.app:

You can edit the files postgresql.conf.sample and pg_hba.conf.sample found in /Applications/Postgres.app/Contents/Versions/15/share/postgresql/ (or the corresponding directories for other versions) which are used as templates during initdb. When doing so, please note that you need to start Postgres.app at least once before to pass the Gatekeeper checks as any modification will likely break the code signature. Also, this kind of modifications need to be repeated after updates of the application.

Further, I'd recommend to have a look to the ALTER SYSTEM SQL command which allows to modify GUCs via the SQL interface that overrides configuration from postgresql.conf. These changes are also dumped by pg_dumpall -g.

@ozum
Copy link
Author

ozum commented Jan 16, 2023

thanks @tbussmann

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

No branches or pull requests

2 participants