fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Serial to parallel execution


From: Jeff Forcier
Subject: Re: [Fab-user] Serial to parallel execution
Date: Fri, 16 Dec 2011 15:43:58 -0800

On Fri, Dec 16, 2011 at 11:36 AM, Hajducko, Steven
<address@hidden> wrote:

> Since if I'm setting a bunch of environment details based on an
> argument, any specific task is going to need the environment defined.  I
> couldn't think of any better way to do this, since a user can basically
> enter the code at any single point

Yes -- this is a long standing problem. I'm running into it myself
lately while trying to clean up some work related code, so it may get
a priority bump soon. Something like:

    @task
    def env(version): <do crap to env based on $version>

    @needs(env)
    def deploy(): <run stuff assuming that the env has been populated>

But I need to think more about the API and implementation so don't
take that as gospel. Point is just the desire to indicate pre/post
execution of related tasks. It's a relatively common feature in this
space so I don't expect to do anything too outlandish.


-Jeff


> -----Original Message-----
> From: address@hidden [mailto:address@hidden On Behalf Of
> Jeff Forcier
> Sent: Thursday, November 17, 2011 10:11 PM
> To: Hajducko, Steven
> Cc: address@hidden
> Subject: Re: [Fab-user] Serial to parallel execution
>
> Hi Steven,
>
> On Wed, Nov 16, 2011 at 5:36 PM, Hajducko, Steven
> <address@hidden> wrote:
>
>> Basic premise is, want to be able to compile ( once ), then parallel
> the push/install.
>> Also want to use roles to be able to selectively decide which
> environment to push to at runtime.
>
> Your posted code is acceptable for what you need to do, given how
> things currently work. However, another possibly cleaner alternative
> would be this:
>
>   address@hidden
>   address@hidden
>    def push():
>        ...
>
>   address@hidden
>   address@hidden
>    def package():
>        ...
>
>   address@hidden
>    def deploy(ver, rolename):
>        <set env vars>
>        execute(package) # runs only once like this anyway, but
> keeping @runs_once doesn't hurt
>        execute(push, role=rolename)
>
> Unless there are bugs (!) you should be able to run this like so
> (note: no global host/role arguments):
>
>    $ fab deploy:1.73,prod
>
> while as a bonus, retaining the ability to run push() or package() as
> regular standalone tasks.
>
> The trick is omitting any global connection params, and instead
> leveraging execute()'s host/role kwargs.
>
> The only downside is that Fab auto-interprets certain task args
> ("host", "roles" etc -- see execution docs) so you have to use some
> name other than "role" or Fab will still end up running 'deploy' with
> a host list.
>
> FWIW, if this pattern becomes more prevalent I might add an option to
> disable auto-interpretation so you can use more natural kwarg names.
>
>> Also, is there a better way to test directory existence that I'm
> missing?
>
> Try fabric.contrib.files.exists :) (It's in the 'contrib' API docs.)
>
>
> Best,
> Jeff
>
> --
> Jeff Forcier
> Unix sysadmin; Python/Ruby engineer
> http://bitprophet.org



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org



reply via email to

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