python - How to specify env.shell while in fabric.operations.execute -
i using fabric.tasks.execute execute commands on remote servers, , need use different shell depending on system. code like:
def run_test(server_ip, server_shell): execute(test,server_ip,server_shell,host=server_ip) # host can specified in execute argument def test(ip,shell): env.shell=shell run('command') i can live prefer execute specifing env.shell command use instead of assigning within task, that's simple , clean. can use like:
def run_test(server_ip, server_shell): execute(test,server_ip,server_shell,host=server_ip,*shell=server_shell*) # host can specified in execute argument def test(ip,shell): run('command')
execute() docs host, hosts, role, roles , exclude_hosts keyword parameters special; rest passed task i.e., shell passed test():
def test(shell): settings(shell=shell): run('command') execute(test, shell=server_shell, host=server_ip)
Comments
Post a Comment