fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Executing script on localhost without ssh


From: Taras Mankovski
Subject: Re: [Fab-user] Executing script on localhost without ssh
Date: Mon, 7 Sep 2009 21:53:17 -0400

Hello Jeff,

I'm familiar with local function.

I agree with you that adding complexity to the code to satisfy a rare
use case is not wise.

At the same time, i think it would make it easier for the user to use
fabric. The user will not have to think in terms of remote or local
server. The user will only need to think about what s/he wants done.

I think local should be more like a context(or environment), rather
then a function for executing commands.

for example,

def local():
     env.hosts['localhost']

I think it would be more elegant to say:

def setup():
     run('command on remote server')
     sudo('command on remote server')
     with local():
          sudo('local command')

This would make local a context like cd().

And this syntax would also work for Virtualenv as well. To add to
conversation on
http://wiki.fabfile.org/PopulatePythonVirtualEnvironment

A possible syntax could be:

def setup():
    with run('source bin/activate'):
         run('pip install django') # commands inside of virtualenv
         sudo('/etc/init.d stop')
         sudo('/etc/init.d start')

What do you think?

Taras




On Mon, Sep 7, 2009 at 6:47 PM, Jeff Forcier<address@hidden> wrote:
> Hi Taras,
>
> Firstly, there is a local() operation which (as Matthew suggested)
> uses the 'subprocess' module to do things locally instead of using
> Paramiko. If by some chance you weren't aware of this -- that may be
> your answer. Note that its current implementation does not perfectly
> match up with run()/sudo() in a few ways (capturing behavior, no
> easy-to-use sudo variant) so it's not perfect, but it will work at
> least in the way Christian suggested.
>
> Secondly, while I'm committed to updating local() to eventually be on
> par with its bigger cousins, I don't think that having Fabric detect
> "if Paramiko needs to be used" and then swapping things out, is the
> right way to go here. It doesn't strike me as a very common use-case,
> and would add complexity to the code -- and more importantly, I don't
> see any good reason why SSH should not be used in both situations --
> it's by far the simplest solution to the problem.
>
> If you're having some issues using SSH from the server back to itself,
> we might be able to help you figure out what's wrong -- but I don't
> think modifying Fabric is the answer at this time. Feel free to fill
> us in on the specific circumstances, though!
>
> Thanks,
> Jeff
>
> On Mon, Sep 7, 2009 at 2:32 PM, Taras Mankovski<address@hidden> wrote:
>> Hey Christian,
>>
>> I would prefer for this to happen automatically. It would be great if
>> fabric would determine if paramiko needs to be used, if not then just
>> execute sudo & run through local.
>>
>> But in the absence of this functionality, I think your solution is a good 
>> one.
>>
>> Thank you,
>> Taras
>>
>> On Mon, Sep 7, 2009 at 10:05 AM, Christian Vest
>> Hansen<address@hidden> wrote:
>>> I don't think it is possible to use run, sudo, get & put without
>>> opening SSH connections, but you can redefine them in terms of local:
>>>
>>> def dev():
>>>  "..."
>>>  global run, sudo, get, put
>>>  run = local
>>>  def sudo(...):
>>>    local(...)
>>>
>>> and so on. Not terribly elegant, but possible.
>>>
>>> On Mon, Sep 7, 2009 at 6:56 AM, Taras Mankovski<address@hidden> wrote:
>>>> Hello There,
>>>>
>>>> I created a fabfile that setups a remote server for hosting my project.
>>>> I wrote it in such a way that I can execute the script on both the
>>>> production server and the dev server and it should work.
>>>>
>>>> I was wandering, is it possible to configure my fabfile in such a way
>>>> that when i configure dev, it does not go through ssh?
>>>>
>>>> I uploaded my fabfile to gist,
>>>> You're feedback is greatly appreciated.
>>>>
>>>> http://gist.github.com/181654
>>>>
>>>> Thank you,
>>>> Taras
>>>>
>>>>
>>>> _______________________________________________
>>>> Fab-user mailing list
>>>> address@hidden
>>>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>>>
>>>
>>>
>>>
>>> --
>>> Venlig hilsen / Kind regards,
>>> Christian Vest Hansen.
>>>
>>
>>
>> _______________________________________________
>> 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]