fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] How to set config when using fabric "programmatically"?


From: Jeff Forcier
Subject: Re: [Fab-user] How to set config when using fabric "programmatically"?
Date: Thu, 5 Mar 2009 16:14:58 -0500

Hi Heikki,

First, set/get is now simply attribute setting/getting of a global
'config' object. Secondly, you can use a @hosts decorator to set a
specific host list for a given command. Thirdly, I think the docs are
now updated for 0.1.0, so you might want to scope them out for other
changes (there's been a few). Or look a week or two back in the list
archives, Christian and I had a few emails about the specific changes
from 0.0.* to 0.1.0.

Here's a simple fabfile that ought to work if your target hosts A and
B only apply to this one command, and if your username locally is the
same as remotely:

@hosts('host-a', 'host-b')
def uname():
    run('uname -a')


Or a slightly longer version, which sets the host list and username
globally (so, i.e. assuming now that the host list is the same for all
commands, and that the username is not the same as your current
logged-in one):

config.fab_hosts = ['host-a', 'host-b']
config.fab_user = 'username'

def uname():
    run('uname -a')


In terms of compatibility, all versions of Fabric starting with 0.1.*
should be compatible with that kind of syntax.

Best,
Jeff


On Wed, Mar 4, 2009 at 7:39 PM, Heikki Toivonen
<address@hidden> wrote:
> Now I've noticed that there is a bug in 0.8.0 when trying to install
> things on multiple target machines. I upgraded to Fabric 0.1.0 and
> noticed a function I was using is no longer there.
>
> I need to run different commands on different machines, so I tried the
> following simplified example:
>
>    for hostname in ['host-a', 'host-b']:
>        fabric.set(fab_hosts=[hostname], fab_user=username,
>                   fab_password=password, fab_fail='abort')
>        fabric.run('uname -a')
>
> In 0.8.0 it runs, but actually runs the command twice on host-a, and
> does not connect to host-b at all. In 0.1.0 the function set has been
> removed so it raises an exception.
>
> How can I make this work, ideally in a way that would not break with new
> versions of Fabric?
>
> --
>  Heikki Toivonen
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>




reply via email to

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