Re: Connecting to PostgreSQL database using pg_service.conf

"John P. Rouillard" <[email protected]> Mon, 06 Nov 2023 18:13:15 -0500
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
Hello Ivanov:

In message <[email protected]>,
[email protected] writes:
>I'm interested in Roundup Tracker and am currently exploring its
>capabilities.

Thanks for your interest.

>Now I have a question regarding its use with PostgreSQL.
>
>I'm using containerized application servers behind a reverse proxy. 

BTW we have docker images at hub.docker.com look for Roundup.

>My current setup has the PGSERVICE environment variable set for each
>application server, so that psycopg2 can connect to the PostgreSQL
>database using connection information from the pg_service.conf file. It
>allows me to avoid storing database credentials in application-related
>configuration files. 
>
>Is there a way that Roundup Tracker can avoid using the default database
>settings and use the values ​​from pg_service.conf to connect to the
>database?

There is no explicit support in Roundup for this.

However, libpq (which psycopg2 uses) should just use the environment
variable provided Roundup doesn't override it.
(https://www.postgresql.org/docs/current/libpq-envars.html)

Try this. Set the environment variable:

  PGSERVICE=your_service_name

Then remove any values for the settings:

  host, port, user, password, and name

in the rdbms section of the tracker's config.ini. (If you are not
setting some of those values in your pg_service.conf, set them in
config.ini.) Make sure the rdbms backend setting is set to postgresql.

If your pg_service.conf file looks like:

[roundup_roundup]
host=127.0.0.1
port=5432
user=rounduptest
password=rounduptest
dbname=rounduptest

(the defaults for demo mode), run:

  roundup-admin -i tracker_home list status

and see if you get a connection error.

I set thing up as above and it worked for me. It displayed the
statuses for the demo tracker. roundup-admin picked up the settings
from the environment variable and the config file. I am using the
current development tip of the default branch. But nothing done since
release 2.3.0 should affect this AFAICT.

I suspect the same method will work for starting the web frontend, or
other roundup-* commands. If this works, it gives you what you want as
long as you are ok with supporting only one tracker per container.

psycopg2 looks like it can use a "service=service_name" in its connect
method. (Working from https://github.com/psycopg/psycopg2/issues/926.)

It might be a useful enhancement to support 'service' directly in
config.ini. It would be useful when running one roundup server serving
multiple trackers.

If you want to move forward with Roundup and run multiple trackers
with one Roundup server instance, we can work on getting support for
specifying the 'service' in config.ini. You would need to test using
the current development code.

Let me know how this works for you.

Have a great week.
--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.


_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users