Reputation: 720
I am using fabric.tasks.execute to execute commands on remote servers, and need to use different shell depending on system. now my code is like:
def run_test(server_ip, server_shell):
execute(test,server_ip,server_shell,host=server_ip) # host can be specified in execute argument
def test(ip,shell):
env.shell=shell
run('command')
I can live with this but prefer execute specifing env.shell the command will use instead of assigning it within the task, that's just simple and clean. Can i use something like:
def run_test(server_ip, server_shell):
execute(test,server_ip,server_shell,host=server_ip,*shell=server_shell*) # host can be specified in execute argument
def test(ip,shell):
run('command')
Upvotes: 0
Views: 333
Reputation: 414149
execute()
docs say that only host
, hosts
, role
, roles
and exclude_hosts
keyword parameters are special; the rest is passed to the task as is i.e., shell
is passed to test()
:
def test(shell):
with settings(shell=shell):
run('command')
execute(test, shell=server_shell, host=server_ip)
Upvotes: 1