Reputation: 15136
I would like to call "run()" or "sudo()" with fabric to execute a script on a remote host. However, I want to do this from within python, and not from the command line:
so instead of:
fab.py:
def do_something():
print "doing something"
sudo("my_shell_commandline_to_do_something")
and then:
fab do_something
I want to just call do_something from some other python program. How do I do this? How do I supply the remote host IP address, since tehre is no fabricrc file from within python (or is there?)
Upvotes: 1
Views: 1333
Reputation: 15136
Nevermind, I found it myself :)
its:
from fabric.operations import sudo
from fabric.context_managers import settings
with (settings(host_string=remote_ip_address,
user='myuser',
key_filename='/tmp/.ssh/myKey.pem')):
sudo('touch a.txt')
Upvotes: 2