Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Fabric - No hosts found. Please specify (single) host string for connection:

Tags:

python

fabric

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: 
like image 562
Tampa Avatar asked Mar 25 '13 17:03

Tampa


2 Answers

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"
like image 161
Raul Gomez Avatar answered Nov 03 '22 17:11

Raul Gomez


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.

like image 13
girasquid Avatar answered Nov 03 '22 17:11

girasquid