Fail to install on Debian 9 with remote PostgeSQL DB


I’m trying to get Gitlab working on a Debian 9 server using the Packager (apt) version of Gitlab. I’m trying to use a different PostgreSQL database server. I can get the installer to reliably create both the gitlab-srv service account and the gitlab_production database. However there is an installation step that is continuously failing. Unfortunately I see no errors in any logs on either servers hinting at what the problem could be. The apt-get output is shown below. (P.S. if I delete the service account and production database from the DB server, the installer creates them and fail at exactly the same step below.)

Setting up gitlab (8.13.11+dfsg1-8) ...
Creating/updating gitlab-srv user account...
Making gitlab-srv owner of /var/lib/gitlab...
Creating runtime directories for gitlab...
Updating file permissions...
Configuring hostname and email...
Configuring nginx with HTTPS...
Configuring gitlab with HTTPS...
Updating gitlab_url in gitlab-shell configuration...
Registering /usr/lib/tmpfiles.d/gitlab.conf via ucf
/etc/systemd/system/gitlab-mailroom.service.d/override.conf already exist
/etc/systemd/system/gitlab-unicorn.service.d/override.conf already exist
/etc/systemd/system/gitlab-sidekiq.service.d/override.conf already exist
/etc/systemd/system/gitlab-workhorse.service.d/override.conf already exist
Registering /etc/gitlab-shell/config.yml via ucf
Registering /etc/gitlab/gitlab.yml via ucf
Registering /etc/gitlab/gitlab-debian.conf via ucf
Reloading nginx configuration...
dbconfig-common: writing config to /etc/dbconfig-common/gitlab.conf
creating postgres user gitlab-srv:  already exists.
resetting password:  success.
creating database gitlab_production: already exists.
dbconfig-common: flushing administrative password
psql: FATAL:  database "gitlab_production" does not exist
dpkg: error processing package gitlab (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I don’t know where that installer step is getting the production database settings from, but I’ve configured it everywhere I could see an entry for it:


I have noticed some tutorials on the internet talks about a gitlab.rb configuration file, however I was not able to locate this on my system and have created one in:


I also have the pg_trgm extension installed on the gitlab_production database.

I’m assuming that the installer is pre-seeding the database for me since I don’t seem to have the gitlab-ctl and gitlab-rake binaries. (Also the documentation seem to indicate that you only need to do it manually if installing from source.)

Any thoughts about where I should start looking or what I could try (or have I just blatantly missed something)?