Reputation: 555
I have a system that i use to run a fabric script that executes test cases on several other client systems.(via launch_process.sh)
@task
@hosts('controller')
def run_script():
run('/test/launch_process.sh')
#below line didn't work
check_ps()
@task
@hosts('clients')
def check_ps():
run('ps aux | grep myprocess')
when we do fab run_script
it launches the process on other machines (assume machine2,machine3) Now I would like to use 'ps' command to confirm ,the process running or not. But check_ps() runs on 'controller' itself - not on clients.
Any thoughts on how to achieve this ?
(looking for solution ,without using passwdless login and popen or paramiko)
Upvotes: 0
Views: 570
Reputation: 4131
Fabric has execute() now. http://docs.fabfile.org/en/1.4.0/api/core/tasks.html#fabric.tasks.execute
That'll let you do:
@task
@hosts('controller')
def run_script():
run('/test/launch_process.sh')
execute(check_ps, hosts=['client'])
And with that the @hosts on check_ps is still valid in the event you want to run it alone (w/o run_script())
Upvotes: 2