fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] env.user and prev_user in the presence of env.hosts


From: Jeff Forcier
Subject: Re: [Fab-user] env.user and prev_user in the presence of env.hosts
Date: Fri, 15 Apr 2011 15:19:52 -0700

Hi Justin,

On Tue, Apr 12, 2011 at 10:41 PM, Justin Donaldson <address@hidden> wrote:
> First off, congrats on fabric, this is a really useful tool.

Thanks!

> I was confused by some behavior in fabric.  When you set env.user in one
> function, it will typically be passed on to the next, just like any other
> field set on env.
>
> However, when env.hosts are present, env.user is discarded without any
> indication of what's happening.
>
> <snip>
>
> The question is, what is the purpose for this behavior?  I couldn't find
> anything in the documentation that explained why it was doing this.

See http://docs.fabfile.org/en/1.0.1/usage/env.html#user -- it should
explain what is going on.

The best way to work around it for now is to mutate env.users to
prefix the host strings with "username@" instead of setting env.user,
e.g.::

    def user(name):
        env.hosts = [name + "@" + x for x in env.hosts if "@" not in x]

In other words, it would change ['host1', 'host2'] to ['address@hidden',
'address@hidden'].

env.user only really works as intended if set at module level instead
of at runtime (IIRC; it's been a while since I touched this part of
things.) This isn't a very good design and will definitely change in
future releases.

There's work going on now to make tasks more object oriented, for
example, which will straighten a lot of this out instead of relying on
env to be both informational and for configuration.

> The next question is, is there a group of people that are sharing best tips,
> etc. for using fabric on cloud based systems?  Is there a better option? I'd
> rather not invent the wheel, or force square pegs in round holes here.

No specific group, but I would definitely welcome discussion on that
here, and it comes up on IRC relatively frequently as well. I'm
personally using more cloud stuff now than I used to, to say nothing
of the increasing amount of user contributions in the same space -- so
improvements should come along relatively quickly.

Best,
Jeff

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



reply via email to

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