capistrano-foreman icon indicating copy to clipboard operation
capistrano-foreman copied to clipboard

Can not input sudo password when run foreman:restart

Open yesmeck opened this issue 11 years ago • 9 comments

Hello, I'm using the master branch. When I run foreman:restart, capistrano will hang when prompting for sudo password. Should we use foreman_sudo here? https://github.com/hyperoslo/capistrano-foreman/blob/master/lib/capistrano/foreman.rb#L28

yesmeck avatar Jun 17 '13 17:06 yesmeck

Hi @yesmeck,

I'm not sure that will help. Capistrano isn't particularly great with input, so I think you will have to configure your sudoers file so that the command won't prompt for a password (see NOPASSWD).

jgorset avatar Jun 17 '13 18:06 jgorset

Yes, NOPASSWORD is a solution.

But if I chang this line:

run "sudo service #{options[:app]} start || sudo service #{options[:app]}  restart"

to

run "#{foreman_sudo} service #{options[:app]} start || #{foreman_sudo} service #{options[:app]}  restart"

and

set :foreman_sudo, "rvmsudo -p 'sudo password: '"

Capistrano also will works.

yesmeck avatar Jun 17 '13 20:06 yesmeck

I have the same problem. In fact, I think you should just use #{sudo} and use the global capistrano sudo setting.

mcfiredrill avatar Aug 05 '13 18:08 mcfiredrill

I'd really like to implement this, @mcfiredrill, but I can't find any documentation on a sudo variable — could you direct me?

jgorset avatar Sep 01 '13 11:09 jgorset

@jgorset this?

glaszig avatar Dec 30 '13 20:12 glaszig

+1 since upstart supports user jobs and the newer session jobs, you can run upstart jobs without using sudo at all

ralfthewise avatar Feb 05 '14 22:02 ralfthewise

@ralfthewise erm, user/session jobs only start when a user logs in and starts some sort of x session, no? i don't think upstart iterates all users of the system and loads their jobs...

glaszig avatar Feb 05 '14 22:02 glaszig

No, they're just like usual upstart jobs except they run in the context of an unprivileged user. See http://upstart.ubuntu.com/cookbook/#user-job and http://upstart.ubuntu.com/cookbook/#session-job

ralfthewise avatar Feb 05 '14 23:02 ralfthewise

section Session Job:

[...] Session Jobs are not managed by Upstart running as PID 1 - they are managed by the users own Session Init.

section Session Init:

Traditionally, this job has been handled by applications such as "gnome-session" [...]

and then below in section Non-graphical Sessions:

However, what if you want to use a Session Init on a server? This is not fully supported right now, but can be achieved as follows.

Create two System Job similar to the following...

so, as i understand it, those jobs won't be started upon boot but only when the user actively initiates such a session by, e.g., launching gnome or some other tool which in turn only happens when you login.

glaszig avatar Feb 05 '14 23:02 glaszig