Use Capistrano to run ssh commands on many servers

116 views
Skip to first unread message

maxime.l...@dolmen-tech.com

unread,
Apr 17, 2014, 6:33:31 AM4/17/14
to capis...@googlegroups.com
Hi everybody,
I'm currently using capistrano to run ssh command on a server cluster of 10 servers. For the moment, I'm juste making some tests, and I just want capistrano to create a file in the "deploy" user home directory.

Here is my script:
# config valid only for Capistrano 3.1
lock '3.2.0'

set :application, 'PasswordUpdate'
# set :repo_url, 'g...@example.com:me/my_repo.git'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do

    desc 'Test'
    task :test do
        on roles(:app) do
            execute "touch /home/deploy/cap_was_here.txt"
        end
    end

end#  desc 'Restart application'
#  task :restart do
#    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
#    end
#  end

#  after :publishing, :restart

#  after :restart, :clear_cache do
#    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
#    end
#  end

end


And this is what I get when I run cap staging deploy --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
 INFO [214e5ad8] Running /usr/bin/env mkdir -p /tmp/PasswordUpdate/ on ap.mydomain.com
DEBUG [214e5ad8] Command: /usr/bin/env mkdir -p /tmp/PasswordUpdate/
 INFO [214e5ad8] Finished in 0.310 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/PasswordUpdate/git-ssh.sh 0.0%
 INFO Uploading /tmp/PasswordUpdate/git-ssh.sh 100.0%
 INFO [df2aaf1e] Running /usr/bin/env chmod +x /tmp/PasswordUpdate/git-ssh.sh on ap.mydomain.com
DEBUG [df2aaf1e] Command: /usr/bin/env chmod +x /tmp/PasswordUpdate/git-ssh.sh
 INFO [df2aaf1e] Finished in 0.033 seconds with exit status 0 (successful).
** Execute git:check
DEBUG [723adf7b] Running /usr/bin/env git ls-remote -h  on ap.mydomain.com
DEBUG [723adf7b] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/PasswordUpdate/git-ssh.sh /usr/bin/env git ls-remote -h  )
DEBUG [723adf7b] /usr/bin/env:
DEBUG [723adf7b] git
DEBUG [723adf7b] : Aucun fichier ou dossier de ce type
DEBUG [723adf7b]
DEBUG [723adf7b] Finished in 0.307 seconds with exit status 127 (failed).

I've got no idea about why Capistrano is talking me about git, because all about git is commented in my configuration.

I'm using Capistrano on my Mac (Capistrano 3 on MacOSX Mavericks) and target servers are working on Debian.

Lee Hambley

unread,
Apr 17, 2014, 1:09:34 PM4/17/14
to capistrano
I've got no idea about why Capistrano is talking me about git, because all about git is commented in my configuration.

​Re-check the docs, Capistrano requires a SCM server to checkout code from. See also https://github.com/capistrano/capistrano/issues/929

See also https://github.com/capistrano/sshkit which is what the documentation suggests you use if you don't have to checkout something from a source control server.​
Reply all
Reply to author
Forward
0 new messages