postgres db: Create guest user at db initialization time
Related to swh/infra/sysadm-environment#4228 (closed) Related to swh-core!278 (closed)
Test Plan
$ swh-doco up -d swh-scheduler
...
swh-doco exec swh-scheduler-db psql -U postgres
+ cd /home/tony/work/inria/repo/swh/swh-environment/docker
+ docker-compose -f docker-compose.yml -f docker-compose.override.yml exec swh-scheduler-db psql -U postgres
psql (12.11 (Debian 12.11-1.pgdg110+1))
Type "help" for help.
postgres=# select now(), * from pg_roles where rolname='guest';
now | rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid
------------------------------+---------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------+-------
2022-06-07 13:02:37.84723+00 | guest | f | t | f | f | t | f | -1 | ******** | | f | | 16385
(1 row)
$ swh-doco up -d swh-storage
...
$ swh-doco logs -f swh-storage-db
swh-storage-db_1 | 2022-06-07 12:32:23.180 UTC [49] LOG: database system is ready to accept connections
swh-storage-db_1 | done
swh-storage-db_1 | server started
swh-storage-db_1 | CREATE DATABASE
swh-storage-db_1 |
swh-storage-db_1 |
swh-storage-db_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/01-init-guest-user-db.sql
swh-storage-db_1 | CREATE ROLE
...
$ swh-doco exec swh-storage-db psql -U postgres
+ cd /home/tony/work/inria/repo/swh/swh-environment/docker
+ docker-compose -f docker-compose.yml -f docker-compose.override.yml exec swh-storage-db psql -U postgres
psql (12.11 (Debian 12.11-1.pgdg110+1))
Type "help" for help.
postgres=# select now(), * from pg_roles where rolname='guest';
now | rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid
-------------------------------+---------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------+-------
2022-06-07 13:03:26.519636+00 | guest | f | t | f | f | t | f | -1 | ******** | | f | | 16385
(1 row)
Migrated from D7965 (view on Phabricator)