Skip to content Skip to sidebar Skip to footer

Is There A Way To Conduct Rolling Deployment In Fabric Files?

Giving the following fabfile: from fabric.api import env, run env.user = 'implicit_user' env.hosts = ['host1', 'explicit_user@host2', 'host3'] def print_user(): with hide('ru

Solution 1:

Your file already executes sequentially unless you are specifying parallel via the command line. To be explicit about this sequential execution use the @serial decorator .

Do you want this delay to deal with a failure? warn_only=False will cause a failure in one of your sequential tasks to terminate the task (other hosts will not run the task). This is also seen in the example below where as soon as false is run (it has failure exit status) the remaining host do not run the task.

from fabric.api import *
from fabric.decorators import hosts, parallel, serial
import random

@task@serial@with_settings(warn_only=False)defmaybe_fail():
    if random.randint(0,3) == 0:
        run("/bin/false") 
    else:
        run("/bin/true")

If you really want this 10 second delay I guess you could make a decorator that sleeps for 10 or just sleep at the end of your tasks.

Post a Comment for "Is There A Way To Conduct Rolling Deployment In Fabric Files?"