Discussion:
[Fab-user] running parallel executions with different env.user
Stephen Barrett
2017-11-09 20:00:24 UTC
Permalink
Hello,

I'm looking to update a package that uses fabric to interact with a bunch of windows slaves (Cygwin sshd) to do things in parallel. Unfortunately I can't work out how to have fabric use a different env.user for each host, because sadly the hosts require <machinename>+<username> as their login credentials.

For example how would I update this code to run things in parallel for each host?

deployables = init_deployables(release)
# API kill first
hosts = set([options['host'] for options in deployables.values()])
api_killed = False
for host in hosts:
env.user = "{}+autobot".format(host.upper())
api_killed = execute(apikill_apps, host=host)[host] or api_killed

if api_killed:
print "Sleeping 20 seconds to let apps shutdown before attempting to task kill remainders"
sleep(20)

# Cleanup everything remaining with taskkill
for host in hosts:
env.user = "{}+autobot".format(host.upper())
execute(taskkill_apps, host=host)

Thanks!

Stephen Barrett
Brandon Whaley
2017-11-10 00:21:24 UTC
Permalink
Hi Stephen,

I'd probably take advantage of the fact that host strings in fabric can
include the username using @ syntax: ***@host

def deploy(release):
deployables = init_deployables(release)
# API kill first
hosts = set(
'{}+autobot@{}'.format(
options['host'].upper(),
options['host']
) for options in deployables.values()
)
kill_results = execute(apikill_apps, hosts=hosts)
api_killed = any(kill_results.values())

if api_killed:
print "Sleeping 20 seconds to let apps shutdown before attempting
to task kill remainders"
sleep(20)

# Cleanup everything remaining with taskkill
execute(taskkill_apps, hosts=hosts)
Post by Stephen Barrett
Hello,
I’m looking to update a package that uses fabric to interact with a bunch
of windows slaves (Cygwin sshd) to do things in parallel. Unfortunately I
can’t work out how to have fabric use a different env.user for each host,
because sadly the hosts require <machinename>+<username> as their login
credentials.
For example how would I update this code to run things in parallel for each host?
deployables = init_deployables(release)
# API kill first
hosts = set([options['host'] for options in deployables.values()])
api_killed = False
env.user = "{}+autobot".format(host.upper())
api_killed = execute(apikill_apps, host=host)[host] or api_killed
print "Sleeping 20 seconds to let apps shutdown before attempting
to task kill remainders"
sleep(20)
# Cleanup everything remaining with taskkill
env.user = "{}+autobot".format(host.upper())
execute(taskkill_apps, host=host)
Thanks!
Stephen Barrett
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Stephen Barrett
2017-11-10 22:42:09 UTC
Permalink
Worked perfect. Thank you!

Stephen Barrett

From: Brandon Whaley [mailto:***@gmail.com]
Sent: Thursday, November 09, 2017 4:21 PM
To: Stephen Barrett <***@spacex.com>
Cc: fab-***@nongnu.org
Subject: Re: [Fab-user] running parallel executions with different env.user

Hi Stephen,

I'd probably take advantage of the fact that host strings in fabric can include the username using @ syntax: ***@host

def deploy(release):
deployables = init_deployables(release)
# API kill first
hosts = set(
'{}+autobot@{}'.format(
options['host'].upper(),
options['host']
) for options in deployables.values()
)
kill_results = execute(apikill_apps, hosts=hosts)
api_killed = any(kill_results.values())

if api_killed:
print "Sleeping 20 seconds to let apps shutdown before attempting to task kill remainders"
sleep(20)

# Cleanup everything remaining with taskkill
execute(taskkill_apps, hosts=hosts)



On Thu, Nov 9, 2017 at 5:50 PM Stephen Barrett <***@spacex.com<mailto:***@spacex.com>> wrote:
Hello,

I’m looking to update a package that uses fabric to interact with a bunch of windows slaves (Cygwin sshd) to do things in parallel. Unfortunately I can’t work out how to have fabric use a different env.user for each host, because sadly the hosts require <machinename>+<username> as their login credentials.

For example how would I update this code to run things in parallel for each host?

deployables = init_deployables(release)
# API kill first
hosts = set([options['host'] for options in deployables.values()])
api_killed = False
for host in hosts:
env.user = "{}+autobot".format(host.upper())
api_killed = execute(apikill_apps, host=host)[host] or api_killed

if api_killed:
print "Sleeping 20 seconds to let apps shutdown before attempting to task kill remainders"
sleep(20)

# Cleanup everything remaining with taskkill
for host in hosts:
env.user = "{}+autobot".format(host.upper())
execute(taskkill_apps, host=host)

Thanks!

Stephen Barrett

_______________________________________________
Fab-user mailing list
Fab-***@nongnu.org<mailto:Fab-***@nongnu.org>
https://lists.nongnu.org/mailman/listinfo/fab-user

Loading...