2014-03-25 1 views
3

여기 설정에 내 production.rb입니다/각각의 출력을 제공 내가 그들의특정 역할에 대해 역할을 만들고 카피 스트라노 작업을 실행하는 방법은 무엇입니까?

cap HOSTS=198.61.228.160 production check:function_2 
cap HOSTS=198.61.228.160 production check:function_1 

cap HOSTS=198.61.179.237 production check:function_2 
cap HOSTS=198.61.179.237 production check:function_1 

모든 일을하려고

Instance Details 
server '198.61.179.237', :web, :app, :db, primary: true 
server '198.61.228.160', :file_server 

# Rails Environment 
set :rails_env, 'production' 

그리고 deploy.rb

namespace :check do 
    task :function_1, :roles => :web do 
    puts 'function_1' 
    end 
    task :function_2, :roles => :file_server do 
    puts 'filesssss' 
    end 
end 

그러나시에서 배포합니다. 그러나 선언문에 따라

function_1:role => :web에만 사용해야하며 마찬가지로 function_2:role => :file_server에만 사용해야합니다.

어디서 잘못 될까요? 올바른 접근 방법은 무엇입니까?

답변

1

나는 당신이 원하는 것은 cap HOSTFILTER=198.61.228.160 function_2 또는 cap HOSTFILTER=198.61.179.237 function_1

그건이라고 생각하기 때문에 기능의 역할과 당신이 찾고있는 서버와의 모든 서버의 교차에 대한 HOSTFILTER 확인합니다. 좋은 설명이 Pete Hodgson

에 의해 here을 찾을 수 있습니다 또한 우리는 때문에 수동이를 볼 수 있습니다

$ cap -H 

     HOSTS 
      Execute the tasks against this comma-separated list of hosts. 
      Effectively, this makes the host(s) part of every roles. 

     HOSTFILTER 
      Execute tasks against this comma-separated list of host, 
      but only if the host has the proper role for the task. 

     HOSTROLEFILTER 
      Execute tasks against the hosts in this comma-separated list of roles, 
      but only if the host has the proper role for the task. 

     ROLES 
      Execute tasks against this comma-separated list of roles. Hosts which 
      do not have the right roles will be skipped.