From a60fd54e8e5cae7be83ec9e09cfb5492bcea9d38 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Sun, 15 Jan 2023 18:39:43 +0100 Subject: [PATCH] Fix PostgreSQL provisioning --- recipe/provision/databases.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipe/provision/databases.php b/recipe/provision/databases.php index 851b9b2d0..4e46331ba 100644 --- a/recipe/provision/databases.php +++ b/recipe/provision/databases.php @@ -58,6 +58,7 @@ desc('Provision PostgreSQL'); task('provision:postgresql', function () { run('apt-get install -y postgresql postgresql-contrib', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); - run('sudo -u postgres createuser {{db_user}}'); - run('sudo -u postgres createdb {{db_name}}'); + run("sudo -u postgres psql <<< $'CREATE DATABASE {{db_name}};'"); + run("sudo -u postgres psql <<< $'CREATE USER {{db_user}} WITH ENCRYPTED PASSWORD \'%secret%\';'", ['secret' => get('db_password')]); + run("sudo -u postgres psql <<< $'GRANT ALL PRIVILEGES ON DATABASE {{db_name}} TO {{db_user}};'"); });