2016-08-01 5 views
0

Ich habe eine pseudo wieAusführen von Befehlen auf der Grundlage der Rolle innerhalb einer Aufgabe in Capistrano

folgt
task :my_task, roles => [:role1, :role2] do 
    command 1 
    command 2 
    command 3 
    command 4 
end 

I für role1 Befehl 1 & Befehl 2 wird nur ausgeführt werden soll, Befehl 3 & Befehl 4 für role2. Ist das in Capistrano möglich?

Ich habe versucht,

task :my_task, roles => [:role1, :role2] do 
    on roles(:role1) do 
     command 1 
     command 2 
    end 

    on roles(:role2) do 
     command 3 
     command 4 
    end 
end 

aber offenbar nicht für me..Please Hilfe zur Arbeit :)

Btwn verwende ich v2.15.5 Capistrano

Vielen Dank im Voraus

+0

"Scheint nicht zu funktionieren" bedeutet was? Gibt es einen Fehler? – tadman

+0

Es geht überhaupt nicht zum Codeblock "on roles" :) –

+0

Sie haben gesagt, dass Sie Capistrano v2 ausführen, aber ein Teil der Syntax, die Sie geschrieben haben, ist für v3. Das ist ein Grund, warum es nicht funktioniert. Insbesondere gibt es in v2 keine "on roles (...)" -Syntax. –

Antwort

0

Dies ist vielleicht keine gute Möglichkeit, es zu lösen..aber das war alles was ich konnte und es funktionierte für mich.

task :my_task do 
    task_1 
    task_2 
end 
task :task_1, :roles => [:role1] do 
    command 1 
    command 2 
end 
task :task_2, :roles => [:role2] do 
    command 3 
    command 4 
end 
Verwandte Themen