Python Fabric - No hosts found. Please specify (single) host string for connection:
Python Fabric - No hosts found. Please specify (single) host string for connection:
How do I get No hosts found. Please specify (single) host string for connection: ?
How to a resolve with fabric?
def bootstrap():
host = 'ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com'
env.hosts = [host]
env.user = "ubuntu"
env.key_filename = "/home/ubuntu/omg.pem"
> command run
>> fab bootstrap
> No hosts found. Please specify (single) host string for connection:
3 Answers
3
Instead of setting hosts inside your task, do it before it gets called with a decorator:
from fabric.api import hosts, env
@hosts(['ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com'])
def bootstrap():
env.user = "ubuntu"
env.key_filename = "/home/ubuntu/omg.pem"
For more information on this, check out Defining host lists - there are a lot of different ways to do it depending on what you need.
Also you can use env.host_string instead of env.hosts:
def bootstrap():
env.host_string # 'ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com'
env.user = "ubuntu"
env.key_filename = "/home/ubuntu/omg.pem"
Thanks!, I also needed
env.disable_known_hosts = True
– Montaro
Jan 5 '17 at 12:36
env.disable_known_hosts = True
Alternatevly you can set env settings in outside your functions
from fabric.api import env, run
host = 'ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com'
env.hosts = [host]
env.user = "ubuntu"
env.key_filename = "/home/ubuntu/omg.pem"
def test():
run('ls -la')
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks for this solution. I was having an issue where i need to define different type of hosts to a different function. With this solution i was able to fix my problem.
– fear_matrix
Jan 9 '17 at 10:17