semaphore: Unable to connect to Postgres from Docker with sslmode disabled.

No env var SEMAPHORE_DB_OPTIONS for Docker image to disable sslmode for Postgres.

https://github.com/ansible-semaphore/semaphore/issues/745#issuecomment-1082980602

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 17

Most upvoted comments

Hi there - thanks for raising this issue. I believe the main change will be in this file: deployment/docker/common/semaphore-wrapper

Perhaps we could do something like this:

Provide an env var called SEMAPHORE_DB_OPTIONS_SSLMODE with an empty default value.

SEMAPHORE_DB_OPTIONS_SSLMODE="${SEMAPHORE_DB_OPTIONS_SSLMODE:-}"

And then some code in the wrapper file that does something like:

if [ "${SEMAPHORE_DB_OPTIONS_SSLMODE}" = "disabled" ]; then
# insert code here to make it work
# we need to add: ?sslmode=disabled to the connection string
...
fi;

And then later in the same file, around line 71, we’ll need to include this when writing the config file.

Sorry I can’t be more help. I don’t really understand how this wrapper creates the config file that can be read by Semaphore but hopefully this will help steer someone in the right direction.

Great, so sslmode is now disabled by default.

…but I need sslmode to work with my Postgres.

🤦

@abeastmal @Zorlin Setting this as a environment variable in my configmap for kubernetes worked; SEMAPHORE_DB_OPTIONS: '{ "sslmode": "require" }'

@fiftin I saw this in my container (I’m running it in kubernetes BTW, latest image)

time="2024-03-27T12:08:24Z" level=warning msg="pq: pg_hba.conf rejects connection for host \"10.244.0.107\", user \"semaphore\", database \"semaphore\", SSL off"
panic: pq: pg_hba.conf rejects connection for host "10.244.0.107", user "semaphore", database "semaphore", SSL off

Allowing non ssl connections was the only workaround for now