0

I'm using a library that only supports password authenticated login to psql. So solve this I've edited the pg_hba.conf file as per the doc.

I have a scripted install of my app and psql, and would like to enable local password login problematically from this bash script. Is there a more clever way than using sed or something similar? It sounds a bit "hackish" to alter the config and restarting the service.

4
  • Hi. Are you looking to login with cmd on a local machine (assuming that you are logged in on Linux)? Apr 16, 2019 at 10:00
  • Aside: if you really are using PostgreSQL 9.1 (since it is in the link you provide), you should really try to upgrade... Apr 17, 2019 at 23:18
  • 1
    If you have a scripted install of your application and PostgreSQL, why can't you ship your PostgreSQL install with a specific pg_hab.conf that is already formatted the way you need it for your application/library connecting to it? No need to change it afterwards. Apr 17, 2019 at 23:20
  • They are not always compatible with all versions of PSQL DB.
    – psv
    Apr 25, 2019 at 8:34

1 Answer 1

2

This would be a task for a decent config management implementing idempotent actions.

For example ansible has a module called lineinfile for this particular job.

I'm not sure whether it's the best solution to directly edit file pg_hba.conf. Maybe you want to create the database and explicitly add users with the ansible modules for Postgresql.

Implementing ansible just for this requirement might seem a bit heavy-weight but your question heads in a direction of automating things anyway.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .