[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Running commands on multiple servers in a command

From: Jeff Forcier
Subject: Re: [Fab-user] Running commands on multiple servers in a command
Date: Wed, 20 May 2009 13:29:14 -0400

On Wed, May 20, 2009 at 1:06 PM, Jorge Vargas <address@hidden> wrote:

> Awesome recipe it should be documented on sphinx? I wanted to switch
> host at runtime too.

Hi Jorge,

Well, it's not documented yet because that's not what I want the final API to
look like. As of right now, in fact, one could use the new (but documented, I
think) ``settings`` context manager, i.e.::

    with settings(host_string='server1'):
        value = run('foo')
    with settings(host_string='server2'):
        run('bar %s' % value)

Additionally, there's no real reason (as far as I can tell) not to do something
like this::

    env.my_var = None

    def deployA():
        env.my_var = run('foo')

    def deployB():
        run('bar %s' % env.my_var)

followed by::

    $ fab deployA deployB

Again, though, I want to think this sort of thing through more before I declare
any best practices. For example, you can't (currently) call the above
deployA/deployB functions from another function, because of the way @hosts and
friends work right now (they set an attribute on the function which is only
read if the function is invoked directly via ``fab <function name>``.)

At any rate, my older example, and the first example in this email, should both
work OK as-is. Chances are that any updates to the execution model (as in the
previous paragraph) will occur between the 0.9 final release, and 1.0.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]