开发者

Why does fabric report "No hosts found"?

开发者 https://www.devze.com 2023-02-16 03:39 出处:网络
env.roledefs = { \'seed\': [\'host1\'], \'peer\': [\'host2\'] } @roles(\'seed\') def test(): pass @roles(\'peer\')
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:

  • http://docs.fabfile.org/en/1.4.0/api/core/tasks.html#fabric.tasks.execute
  • http://docs.fabfile.org/en/1.4.0/usage/execution.html#intelligently-executing-tasks-with-execute


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

0

精彩评论

暂无评论...
验证码 换一张
取 消