fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Different roledefs per task


From: Gilgamezh
Subject: Re: [Fab-user] Different roledefs per task
Date: Tue, 18 Dec 2012 15:09:52 -0300
User-agent: Roundcube Webmail/0.8.4

Hi!

you can use execute()

for example

env.roledefs = {
    'db': ['db1', 'db2'],
    'web': ['web1', 'web2', 'web3'],
}

execute(sometask,role='web')
execute(other_task,role='db')

And the other way is here http://docs.fabfile.org/en/1.4.1/usage/execution.html#execute

Regards!




El 2012-12-18 13:50, Francisco José Marques Vieira escribió:
Hi everyone! This is my first post on this mailing list, so please
excuse me if I don't follow some rule or convention of yours.
My name is Francisco and I started using Fabric a couple weeks ago,
and so far I'm happy with what I've seen.
Nevertheless, there always comes a time when even the best tool fails
to accomplish some task, and that's why I'm here.

The thing is, I have two different ways to group my hosts: one is by
role (master or slave), the other is by staging or production, i.e.
there is a master and many slaves in staging, and another master and
many slaves in production.
I have tasks that I need to run only on the master and others to run
in the slaves. Also, I want to be able to run tasks only on staging or
only on production.

The way I've been handling this is by having two different roledefs,
one for master hosts and another for slaves. Each roledef has two
roles, staging and production, meaning I can do something like "fab
deploy -R staging" and this makes sure I won't be installing things
into production by mistake.
These roledefs are defined in a settings file and each fabfile of
mine imports one of them and sets env.roledefs to it.

This works as long as all the tasks in each file are to be executed
in hosts with the same role, either master or slaves. And so far
that's what happened naturally.
Now I have a fabfile which has some tasks that should run in the
master host and another task that should run in the slaves, but I have
no way of saying to fabric "please use a different roledef for this
task", since by the time my code inside the task starts to execute,
the roledefs have already been processed.
Is there any way around this which does not require me to separate
the tasks in two different files?

Francisco Vieira


P.S: Sorry for the such a big post for such a trivial matter...

_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user



reply via email to

[Prev in Thread] Current Thread [Next in Thread]