[Top][All Lists]
[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: |
Thu, 17 Nov 2011 22:11:19 -0800 |
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:
@task
@parallel
def push():
...
@task
@runs_once
def package():
...
@task
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