[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] How do I use Fabric to SSH to two different ports on the
From: |
Jeff Forcier |
Subject: |
Re: [Fab-user] How do I use Fabric to SSH to two different ports on the same server? |
Date: |
Fri, 17 Feb 2012 21:07:40 -0800 |
Hi Michael,
On Thu, Feb 16, 2012 at 7:01 AM, Michael Maley <address@hidden> wrote:
> I’d really like the tasks after the execute() to run as the original user
> (mmaley). Am I doing something incorrectly, or is this a limitation of how
> the context gets passed into/out of execute()?
This is a sorta-bug in execute(): tasks called within execute() may
modify the global env, which is sometimes desirable, but also causes
"bleed" of connection-related parameters -- that's what you're seeing.
Regardless of whether that's changed, calling execute() within a task
that has its own host list is discouraged -- you happen to have set
env.hosts to a single-item list, but if it's ever set to N>1 hosts,
secondSSH will get run N^2 times.
What you probably want instead, which will also get around the state
bleed problem, is either:
* Make firstSSH purely a "meta" task that only calls execute() on
subroutines, and doesn't use run() itself, or:
* Explicitly control the target host for your run() calls by dropping
env.hosts for "with settings(host_string=<host string>):"
* This works because of this:
http://docs.fabfile.org/en/1.4.0/usage/library.html#connections
* Example: https://gist.github.com/9af563bb76f9f806bac2
Hope that helps somewhat.
Best,
Jeff
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org