fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Fabric 0.1.0 ran away from home.


From: Jeff Forcier
Subject: Re: [Fab-user] Fabric 0.1.0 ran away from home.
Date: Mon, 16 Feb 2009 18:37:08 -0500

On Mon, Feb 16, 2009 at 6:04 PM, Christian Vest Hansen
<address@hidden> wrote:

> So! I decided that it was about time for a new release anyway, and I
> suspect those of you who follow the master branch would like the
> online docs, and the releases for that matter, to sync up!

*cheers*

Some corrections/expansions from my end of things, and apologies for
the length (it's all pretty important, folks!):


>  * Output capturing - run ad sudo will return a tuple of what was
> printed to stdout as a string, and an exit code.

That's actually their internal representation, but as exposed to
users' fabfiles, they simply return stdout as a string -- the exit
code gets eaten by Fabric and used to figure out if the command worked
or not (and error/warn accordingly). See example after next bullet
point for how this is used.


>  * Both commands and their failures can now be told to keep quiet.

This is via the config variable 'fab_quiet', by the way :) and its
purpose is to hide the Fabric status messages, usually prefixed with
[run] or [stdout] or whatnot, as well as the normal printing of stdout
and stderr. This allows you to have greater control over the output of
your Fabfile, and is useful if you only need to print 3 lines of text
but your remote commands would result in lots of output.

Example (note also line 3 which shows how run() now returns stdout):

def my_task():
    config.fab_quiet = True
    num_lines = len(run('ls -l /tmp/').split('\n'))
    print "Number of files in /tmp/: %s" % num_lines

This will not print either the line stating that "ls /tmp/" is being
executed, nor the stdout from that command (the list of files), but
only "Number of files in /tmp/: N".

Currently, fab_quiet also hides warnings, but anything that aborts
execution of Fabric will still have its error message appear prior to
exiting.


>  * "fanout" and "rolling" fab_modes are now deprecated in favor of
> "broad" and "deep," though these are not quite equivalent. Also,
> unsupported fab_modes will be frowned upon.

When in deep mode (config.fab_mode = 'deep', or adding @mode('deep')
to your function(s)) commands will be executed fully once per host,
instead of the default ("broad") behavior of once only, with each
operation (e.g. run/sudo/put) executed once per host.

Deep mode was introduced because without it, it's not possible to
perform sensible logic on more than one host: if a single run()
command hits multiple servers at once, it's impossible to perform
logic on the order of "if the server is Debian, modify /etc/apache2;
if it's RedHat, modify /etc/httpd/".

Additionally, the "returns stdout" behavior of run() and sudo()
basically requires the use of deep mode, again because without it
you'd get a list of strings, not a string.


Phew, that's it for now. Even bigger changes for Fabric are on the
horizon, if all goes well, but I won't go into that until something
substantial materializes.

Best,
Jeff




reply via email to

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