Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ended up posting a question on the capistrano users list <a href="http://groups.google.com/group/capistrano/browse_thread/thread/592ab63dda72d7e" rel="noreferrer">here</a>, and got the following response from Jamis (edited a bit by me here for clarity):</p> <hr> <p>Try the HOSTS environment variable:</p> <pre><code>cap HOSTS=app2.example.com production deploy </code></pre> <p>Note that doing this will treat app2 as being in every role, not just whichever role(s) it happens to be declared in.</p> <p>If what you want is to do a regular deploy, but only act on app2, and only as app2 is declared in your recipe file, you can use the HOSTFILTER variable instead:</p> <pre><code>cap HOSTFILTER=app2.example.com production deploy </code></pre> <p>[...]</p> <p>Consider this concrete example. Suppose your script defines three servers, A, B, and C. And it defines a task, "foo", that (by default) wants to run on A and B, but not C. Like this:</p> <pre><code>role :app, "A", "B" role :web, "C" task :foo, :roles =&gt; :app do run "echo hello" end </code></pre> <p>Now, if you do <code>cap foo</code>, it will run the echo command on both A and B.</p> <p>If you do <code>cap HOSTS=C foo</code>, it will run the echo command on C, regardless of the :roles parameter to the task.</p> <p>If you do <code>cap HOSTFILTER=C foo</code>, it will not run the echo command at all, because the intersection of (A B) and (C) is an empty set. (There are no hosts in foo's host list that match C.)</p> <p>If you do <code>cap HOSTFILTER=A foo</code>, it will run the echo command on only A, because (A B) intersected with (A) is (A).</p> <p>Lastly, if you do <code>cap HOSTFILTER=A,B,C foo</code>, it will run the echo command on A and B (but not C), because (A B) intersected with (A B C) is (A B).</p> <p>To summarize: HOSTS completely overrides the hosts or roles declaration of the task, and forces everything to run against the specified host(s). The HOSTFILTER, on the other hand, simply filters the existing hosts against the given list, choosing only those servers that are already in the tasks server list.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload