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

[description]:

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"

fab boostrap
No hosts found. Please specify (single) host string for connection: 
[solution]

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"

posted @ 2016-04-30 11:18  cn_wk  阅读(253)  评论(0)    收藏  举报