fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Executing a task with an empty roledef


From: Jeff Forcier
Subject: Re: [Fab-user] Executing a task with an empty roledef
Date: Wed, 16 May 2012 15:48:38 -0700

On Wed, May 16, 2012 at 2:11 PM, Dan Craig <address@hidden> wrote:

> def deploy():
>     execute(operate_on_web)
>     execute(operate_on_db)
>
> But when I run "fab cluster_without_db deploy", it still executes
> operate_on_db, even though there are no hosts in the 'db' roledef. I had
> expected it to not execute at all. Am I doing something wrong, or is this
> the way it's supposed to work?

I assume that it runs and probably then prompts you for a host since
it has an empty host list? If so, yes, that is how it's supposed to
work -- there's no "skip a task that has no valid hosts" logic
(otherwise your cluster setup tasks wouldn't even work, for example,
as they have no hosts set for them either.)

If you want deploy() to skip running the DB subtask when there's no DB
role, you could simply wrap the 2nd execute() in an 'if' statement,
e.g. "if 'db' in env.roledefs: execute(...)".

Best,
Jeff

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



reply via email to

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