Re: Tips on maintaining several pg_hba files

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alfredo Palhares <alfredo(at)palhares(dot)me>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tips on maintaining several pg_hba files
Date: 2017-01-26 00:24:04
Message-ID: CAB7nPqRt3zN0qVRuc0=xJkgGPVBc82xmY=Z4_T9WsbJ+dPFi7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 26, 2017 at 2:36 AM, Alfredo Palhares <alfredo(at)palhares(dot)me> wrote:
> I have a PostgreSQL cluster with several ROLES that access the node
> according to his state.
>
> On the master node, I only want the roles that need to write and the admins.
> On the synchronous node i would want only roles with read access that
> require the most up to date data, and the admins
> On the asynchronous node allow roles with read acess, and users to debug the
> system.
>
>
> So I will probably be templating the pg_hba.conf file since there are
> common roles between the systems.
> Do you guys have any suggestions on this? Links?
>
> Does pg_hba support to include files?

You cannot include an entire file, but it is possible to list users
and/or databases via files specified by @:
https://www.postgresql.org/docs/9.6/static/auth-pg-hba-conf.html

Particularly this bit:
Files included by @ constructs are read as lists of names, which can
be separated by either whitespace or commas. Comments are introduced
by #, just as in pg_hba.conf, and nested @ constructs are allowed.
Unless the file name following @ is an absolute path, it is taken to
be relative to the directory containing the referencing file.

So you could take advantage of that to handle your configurations on
different nodes with the same pg_hba.conf, but different users and
databases.
--
Michael

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-01-26 00:31:15 Re: Fwd: I could not see any row in audit table
Previous Message Tomas Vondra 2017-01-25 22:06:44 Re: How does Postgres estimate the memory needed for sorting/aggregating