fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Different roledefs per task


From: Francisco José Marques Vieira
Subject: [Fab-user] Different roledefs per task
Date: Tue, 18 Dec 2012 16:50:40 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0

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...



reply via email to

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