sudo: usermod: command not found

3,749 views
Skip to first unread message

Greg Pederson

unread,
Aug 4, 2010, 10:15:19 PM8/4/10
to Capistrano
Hi All,
I wonder if someone may be able to point me in the right direction
with an issue I'm having.

I inherited an app and the staging was pointed to the previous dev's
server. So I updated the deploy/staging.rb file and ran
cap staging deploy:setup

but failed with
* executing "sudo -p 'sudo password: ' usermod --gid
app_scan_staging --home /var/www/scan_staging app_scan_staging"
servers: ["scandesign.com"]
[scandesign.com] executing command
** [out :: scandesign.com] sudo: usermod: command not found
command finished
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' usermod --gid
app_scan_staging --home /var/www/scan_staging app_scan_staging'" on
scandesign.com

I went into my server as the user that's set in the deploy.rb which is
set :user, "scandesignwebsite"

and saw that usermod wasn't found. So I added /usr/sbin to that
user's path
[scandesignwebsite@app01 ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/scandesignwebsite/
bin:/usr/sbin

I then ran the failing command manually with no problem
[scandesignwebsite@app01 ~]$ sudo usermod --gid app_scan_staging --
home /var/www/scan_staging app_scan_staging
Password:
[scandesignwebsite@app01 ~]$


However, when I try to run cap staging deploy:setup again it still
fails because of usermod

And here are the versions I'm running at the moment
greg-pedersons-computer-2:scandesign gspederson$ cap --version
Capistrano v2.5.18
greg-pedersons-computer-2:scandesign gspederson$ ruby --version
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin9]

Thanks in advance for your help.
Greg

Lee Hambley

unread,
Aug 5, 2010, 2:59:42 AM8/5/10
to capis...@googlegroups.com
Hi Greg,

By design Capistrano will ignore a user's login files (~/.profile, ~/.bash_login, /etc/profile, and the rest (system dependent). You should always endeavour to set the full path to executables.

An example might be:

set :usermod, '/usr/sbin/usermod'

This way you'll also need to modify the task in question (which is an extension in your app, as it's not a standard part of the deploy) to something like run("#{usermod} --gid") (so, variable interpolation)

The alternative, if you don't wish to do that is to use the :default_environment (magic undocumented) variable, there's a short and sweet guide here on RVM's site about how it is used, but you can use that to set the environmental variables.

This second method might be a short-term solution, but will pollute the logs and output with this stuff before every command that is run(). Here's an example:

set :default_environment, {
  'PATH' => "/usr/local/bin:/usr/sbin:$PATH",

I hope this helps Greg!

- Lee H


--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Greg Pederson

unread,
Aug 5, 2010, 4:00:29 PM8/5/10
to capis...@googlegroups.com
Thank you Lee, your information helped me get past that usermod not found problem.  Another quick question though...hope you don't mind :)

It seems that cap deploy:setup is trying to run nginx stuff, however this server is apache and nginx isn't installed.  Is the apache vs nginx vs both set by default or manageable?  This is probably an easy fix but I can't seem to find any info.

Thank you again,
Greg

Lee Hambley

unread,
Aug 5, 2010, 4:15:30 PM8/5/10
to capis...@googlegroups.com
Greg,

Almost certainly the NGinx stuff is of your inheritance, there's nothing in the default deploy that assumes to know how to restart your web servers, only the application servers.

- Lee
Reply all
Reply to author
Forward
0 new messages