Reputation: 46497
I'm looking for a way to edit pg_hba.conf
programmatically, similar to how pg_conftool
allows you to edit postgresql.conf
:
~$ pg_conftool 11 main set timezone 'UTC'
I tried using pg_conftool
to edit pg_hba.conf
. Unfortunately, it only allows key = value
entries to be added / removed, which is not the format pg_hba.conf
expects.
I can use echo
and sed
to achieve what I want, but I'm wondering if there's a better way. I found a tool pg_hba
in postgresql-common
that seems to be what I'm looking for:
https://salsa.debian.org/postgresql/postgresql-common
https://salsa.debian.org/postgresql/postgresql-common/blob/master/pg_hba
I have postgresql-common
version 201.pgdg18.04+1
installed, however, I can't figure out how to access / install / invoke pg_hba
.
Is the pg_hba
tool the right tool for the job? If yes, how do I "install" the pg_hba
binary for Ubuntu? If no, is there another recommended approach for programmatically editing pg_hba.conf
?
Upvotes: 3
Views: 1314
Reputation: 311
We don't have a good way for editing pg_hba.conf yet. The pg_hba binary you found is still a WIP. If it works for you, please tell us, and we can work out if installing it to /usr/bin makes sense.
What works now is "pg_conftool 11 main pg_hba.conf edit", but that will just give you an editor.
Another option might be http://augeas.net/, it has a Pg_Hba "lens". (Puppet supports that natively.)
Upvotes: 4