Krikri::PluginHelpers::PostgresqlConnection
PostgresqlConnection - pure logic for building a postgres:// connection URI from Ansible-style login_* params. No I/O - postgresql_db.cr/postgresql_user.cr do the actual DB.open.
Constants
unix_socket, given, takes precedence over host/port (matches real
Ansible's postgresql_db/postgresql_user own login_unix_socket
precedence). crystal-pg expects a unix socket path via a "host"
query param, not the URI's own host component (verified against
its actual conninfo parsing source, not assumed) - the URI host
is left blank in that case.
Debian/Ubuntu's postgresql-common packaging (the target of every
real-host benchmark round so far) compiles libpq's default Unix
socket directory to this path - matches postgresql.conf's own
unix_socket_directories default there.
Class methods
Resolves the login_host:/login_port:/login_user:/
login_unix_socket: params from a plugin's raw @params,
falling back to each one's real-Ansible deprecated alias
(host:/port:/login:/unix_socket: respectively -
login_password: has none) when the canonical login_* form
isn't set. Shared by postgresql_db.cr/postgresql_user.cr/
postgresql_privs.cr so the alias list only lives in one place.
Real bug found benchmarking robertdebock.postgres (round 43):
its own "Create postgres users" task writes port: "{{ postgres_port }}" (the alias, for a non-default port like
6543) - each plugin only ever read login_port:, so the
connection silently fell back to port 5432's Unix socket
instead, which doesn't exist on this host at all
(DB::ConnectionRefused / PQ::ConnectionError: Cannot establish connection, confirmed via direct debug instrumentation
against a live host - the same URI, built by hand with the
correct port included, connected via psql immediately).