when I run my python code it is asking for host.
No hosts found. Please specify (single) host string for connection:
I have the following code:
from fabric.api import *
from fabric.contrib.console import confirm
env.hosts = [ 'ipaddress' ]
def remoteRun():
print "ENV %s" %(env.hosts)
out = run('uname -r')
print "Output %s"%(out)
remoteRun();
I even tried running fab with -H option and I am getting the same message. I’m using Ubuntu 10.10 any help is appreciated. Btw I am a newbie in Python.
I am not exactly sure what
remoteRun();is supposed to do in your example.Is it part of your fabfile or is this your terminal command to invoke the script?
The correct way would be a command like this in your shell:
fab remoteRunGenerally it’s better to specify the concrete hosts your command is supposed to run on like this:
You can run it like this from a terminal (assuming you are in the directory that contains your fabfile):
As an alternative you could specify the host with the -H parameter:
If you have a list of hosts you want to invoke the command for, do it like this:
http://readthedocs.org/docs/fabric/latest/usage/execution.html
Adjusted to your example:
And called via:
fab remoteRunThis way the
remoteRunis performed on all hosts inenv.hosts.