fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] road to 0.1.0


From: Jeff Forcier
Subject: Re: [Fab-user] road to 0.1.0
Date: Sat, 12 Jul 2008 18:11:29 -0400

On Sat, Jul 12, 2008 at 12:56 PM, Jeff Forcier <address@hidden> wrote:

> I've been avoiding actually taking a stab at hacking up this parallel
> approach, but I think I should go ahead and give it a try

Well, my first attempt can be found here:

http://github.com/bitprophet/fabric/commit/438bf959adafe58dbf87129d1ba91fb15eef4aca

Pushed my experimental "execution" branch to Github, which contains a
whopping one commit, but it's a biggish one. I expect there to be bugs
and/or things done in a less-than-ideal fashion (ones I know of:
there's some code duplication between the original "rolling" strategy
and the newer "deep" mode, and while I think passing host info via ENV
works OK now it'll probably need rethinking if/when deep-mode
threading is put in).

But it works in the base case: imagine this fabfile:

set(fab_hosts=['address@hidden', 'localhost'], fab_mode='deep')
def test():
    run('echo "I\'m on %(fab_host)s!"')
    if get('fab_host') == 'localhost':
        run("ls")

It gets this output:

address@hidden sysadmin $ fab test
   Fabric v. 0.0.8, Copyright (C) 2008 Christian Vest Hansen.
   Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab warranty'.
   This is free software, and you are welcome to redistribute it
   under certain conditions; type `fab license' for details.

Running test...
Logging into the following hosts as jforcier:
    localhost
Logging into the following hosts as cyrus:
    bitprophet.org
[localhost] run: echo "I'm on localhost!"
[localhost] out: I'm on localhost!
[localhost] run: ls
[localhost] out: Desktop
[localhost] out: Documents
[localhost] out: Downloads
[localhost] out: Library
[localhost] out: Movies
[localhost] out: Music
[localhost] out: Pictures
[localhost] out: Public
[localhost] out: Sites
[bitprophet.org] run: echo "I'm on bitprophet.org!"
[bitprophet.org] out: I'm on bitprophet.org!
Done.


As expected, it only runs the "ls" if the host is localhost. Once
capturing is in, the same sort of conditional execution should work
fine.

Running the exact same fabfile without setting fab_mode="deep" (since
the default is "broad", or the old way of doing things) will work
fine, but will never execute the "ls" since ENV['fab_host'] is never
set outside of the operations in that mode.

As you can see from the commit diff, I basically removed the concept
of strategies as drop-in functions, as I can't really imagine another
execution strategy aside from the four possible ones: broad serial
(rolling), broad parallel (fanout), deep serial (currently the only
deep mode) and deep parallel (threading applied to commands). Would be
trivial to revert that part of the change (technically I could make it
a separate commit -- didn't think it was worth it) if it was felt that
having drop-in submodes to broad is still a good idea :)

>From here, I'll probably poke at this a bit more and try to clean it
up a bit, or forge ahead and see about getting capturing implemented.

-Jeff




reply via email to

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