Postgres createuser error

377 views
Skip to first unread message

Cyrille

unread,
Jul 16, 2009, 12:13:33 AM7/16/09
to deprec - deployment recipes for capistrano
Hi there,

I get an an error when I run:

cap deploy:setup

Here is the error:

* executing `deprec:rails:setup_database'
* executing `deprec:postgresql:create_user'
* executing "sudo -p 'sudo password: ' su - postgres -c 'createuser -
P -D -A -E postgres'"
servers: ["X.X.X.X"]
[X.X.X.X] executing command
command finished
failed: "sh -c \"sudo -p 'sudo password: ' su - postgres -c
'createuser -P -D -A -E postgres'\"" on X.X.X.X

If I ssh on to the server and run:

sudo su - postgres -c 'createuser -P -D -A -E postgres'

It asks me for:

Enter password for new role:

Why is it not asking me for the new role's password interactively?

Cheers

Cyrille

Cyrille

unread,
Jul 16, 2009, 12:24:56 AM7/16/09
to deprec - deployment recipes for capistrano
Hmm looking at the code of create_user, it seems that it should send
the password.

So, on the server, I ran:

sudo su - postgres -c 'createuser -P -D -A -E postgres'

And answered all the questions.

It then fails with message:

createuser: creation of new role failed: ERROR: role "postgres"
already exists

Could it be the problem? Should the script test if the user postgres
already exist? I didn't create the "postgres" user, but obviously some
script must have.

Cheers

Cyrille

Cyrille

unread,
Jul 16, 2009, 12:43:19 AM7/16/09
to deprec - deployment recipes for capistrano
Digging deeper, the problem is that I use the "postgres" user for my
DB connection.

So, I tried to change the DB user and found an odd problem.

I am deploying to a staging server, but deprec always uses the DB user
from production.

I think it is because of line 11 in lib/deprec/recipes/rails.rb:

set :rails_env, 'production'

Shouldn't rails_env be retrieved from the command line RAILS_ENV
parameter?

Cheers

Cyrille

On Jul 16, 4:13 pm, Cyrille <cbonne...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages