I want to run a method on several remote hosts in parallel through Python script.
I have their credential (ip,usr,pass).
in order to do it I decorate the method with @parallel
, and called it via execute()
where I gave all hosts.
my question is how do I set env.usr
, env.password
for each task?
here is an example of my code:
class deployment()
__init__():
self.hosts = read_ips_from_csv
def do_something(self)
run(remote_command)
def run_remote(self,func):
execute(func,hosts = self.hosts)
def deploy(self):
run_remote(self.do_something)
main():
my_deploy = deployment()
my_deploy.deploy()
the question is how to set the env
parameters for each host in do_something()
thanks a lot for your answers!!