avances123
avances123

Reputation: 2354

Calling a fabric nested method with fewer hosts in decorator

I have

@roles('production')
def submethod():
    run('service restart')


@roles('all')
def deploy():
    put('somefile.conf')
    submethod()

I call deploy(), but then all services are restarted, in all hosts, what is the best way to get this done? It seems the @roles('production') is not working...

Thanks a lot.

Upvotes: 1

Views: 161

Answers (1)

alecxe
alecxe

Reputation: 474041

If you want to call a task from another task, you should use execute:

def submethod():
    run('service restart')


@roles('all')
def deploy():
    put('somefile.conf')
    execute(submethod, roles=['production'])

Hope that helps.

Upvotes: 1

Related Questions