简体   繁体   中英

Why does fabric report “No hosts found”?

env.roledefs = {
    'seed': ['host1'],
    'peer': ['host2']
}

@roles('seed')
def test():
    pass

@roles('peer')
def test1():
    pass

def deploy():
    test()
    test1()

fab test, fab test1 - all ok

fab deploy:

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

Why ?

When calling test and test1 from deploy , the @roles are not taken into account. You should call the functions using execute(test) and execute(test1) .

See also:

Because env.hosts is not set. Your test() functions do not use run() or any similar command that requires ssh connection, while deploy(), presumably, does().

Read these first:

http://docs.fabfile.org/en/1.0.1/usage/env.html#hosts

http://docs.fabfile.org/en/1.0.1/usage/execution.html#hosts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM