Bdfy
Bdfy

Reputation: 24729

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 ?

Upvotes: 2

Views: 4305

Answers (2)

Bouke
Bouke

Reputation: 12198

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:

Upvotes: 4

Dmitry Guyvoronsky
Dmitry Guyvoronsky

Reputation: 708

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

Upvotes: 1

Related Questions