fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Logging out as a user


From: Jeff Forcier
Subject: Re: [Fab-user] Logging out as a user
Date: Tue, 23 Mar 2010 11:51:30 -0400

Hi Erich,

Thanks, I had skimmed over the fact that *disconnecting* was the key,
and not making a new one. Sorry for that, Brett :)

The connections are simply Paramiko objects, and can be accessed in
fabric.state.connections (which is a dict whose keys are host
strings.) They can then be .close()'d as you might expect.

For example, see the tail end of Fabric's main execution loop:

    http://code.fabfile.org/repositories/entry/fabric/0.9/fabric/main.py#L439

This stuff isn't part of the API, so keep in mind that it may get
moved around; but it will get added to the API at a later date and at
that point it will be A) easier to use and B) stable.

-Jeff

On Tue, Mar 23, 2010 at 11:34 AM, Erich Heine <address@hidden> wrote:
> My understanding is that the work flow is:
>
> 1. Do fab cleanup actions as address@hidden
> 2. do admin tasks as address@hidden
>
> I think the problem is coming because via the connection cache there is
> still connection and process owned by the UID Brett is trying to delete. Is
> there an easy way to force close a connection?
>
> There will of course be a problem with part 2 if it is being done with a
> sudo() call, since that is the equivelent of sudo rmuser me.  (which fails)
>
> Regards,
> Erich
>
> On Tue, Mar 23, 2010 at 9:50 AM, Jeff Forcier <address@hidden> wrote:
>>
>> Hi Brett,
>>
>> Currently, Fabric's operations like run() and sudo() just look at
>> env.host_string to determine which connection to use (and these are
>> cached.)
>>
>> So to force a new connection as a different user, simply set
>> env.host_string to address@hidden:current_port, and subsequent
>> calls to operations will use that new connection. (Eventually the
>> other env vars will be more intelligently used -- right now they're
>> used for defaults or are effectively read-only.)
>>
>> A one-time overwrite of that setting will make the switch for the rest
>> of the session/script; or you can use the context manager to effect
>> the change only for a single block of code, e.g.:
>>
>>   address@hidden('address@hidden')
>>    def foo():
>>        # Connecting as userA
>>        run('something')
>>        sudo('something else')
>>        with settings(host_string='address@hidden'):
>>            # Connecting as userB
>>            run('something as user B')
>>        # Connecting as userA again
>>        run('yet another something')
>>
>> For more details on how host connections work, see the 'Usage docs'
>> section of docs.fabfile.org.
>>
>> Best,
>> Jeff
>>
>> On Mon, Mar 22, 2010 at 6:22 AM, Brett Haydon
>> <address@hidden> wrote:
>> > I am trying to switch ssh users from A to B and then remove user A on
>> > Ubuntu, but it always says that account A is in use.
>> > I don't seem to be able to explicitly log the user out.
>> > Is there a way to effectively do this?
>> >
>> > Brett H
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > Fab-user mailing list
>> > address@hidden
>> > http://lists.nongnu.org/mailman/listinfo/fab-user
>> >
>> >
>>
>>
>>
>> --
>> Jeff Forcier
>> Unix sysadmin; Python/Ruby developer
>> http://bitprophet.org
>>
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>



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




reply via email to

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