I prefer using execute: http://docs.fabfile.org/en/1.8/api/core/tasks.html?highlight=execute#fabric.tasks.execute On Oct 25, 2013 7:55 PM, "Gilgamezh" <lis...@gilgamezh.me> wrote:
> El 25/10/13 19:20, Nathan Nobbe escribió: > >> Hi everyone, >> >> I've recently started using Fabric (any Python for that matter)! So far >> I'm loving Fabric compared to Capistrano, which is next to useless >> outside of Ruby projects that I can tell. >> >> I have hit a snag with Fabric though, and I'm surprised nobody else >> seems to have dealt with it. I've got sets of nodes that comprise an >> 'environment'. For example, 2 boxes are used as db servers, 2 boxes as >> application servers (not exactly my setup, but that's the idea). >> >> Now I can have 2 tasks for this with @host decorators that map the hosts >> to the deployment logic, however, since there is no way to change the >> hosts within a task, I have to make 2 separate calls to fab on the CLI. >> >> The problem is, I have several sets of nodes and the order of operations >> in the deployment is itself some logic I would like to encapsulate. Best >> approach I have so far is to place the fab calls into a BASH script. >> >> I'm shocked that there's no way to change hosts within a task, and >> moreover that this desire hasn't arisen before. Is there some way to >> change the hosts mid-task? I can't find anything on Google or >> Stackoverflow. Or am I thinking about this the wrong way? Seems like >> grouping the hosts the way I have makes sense. I took a look at roles, >> but I don't think that's any different than say an @host decorator with >> the 'db' servers for example. >> >> Your help appreciated! >> >> thanks, >> >> -nathan >> >> >> > Hi! > > roles are in the env dict. You can do this: > > env.roledefs.update({ > 'webserver': ['www1', 'www2'], > 'dbserver': ['db1'] > }) > > then..... > > for server in env.roledefs['webserver']: > do something > for server in env.roledefs['dbserver']: > do something. > > In all the cases you can set a specific host > > for example: > > with settings(host_string='**somehost.domain'): > do some > > it's just python! :D > > More in: > http://docs.fabfile.org/en/1.**8/api/core/decorators.html?** > highlight=roledefs<http://docs.fabfile.org/en/1.8/api/core/decorators.html?highlight=roledefs> > http://docs.fabfile.org/en/1.**8/usage/env.html?highlight=**roledefs<http://docs.fabfile.org/en/1.8/usage/env.html?highlight=roledefs> > http://docs.fabfile.org/en/1.**8/usage/execution.html?**highlight=roledefs<http://docs.fabfile.org/en/1.8/usage/execution.html?highlight=roledefs> > > > regards! > > Gilgamezh. > > ______________________________**_________________ > Fab-user mailing list > Fab-user@nongnu.org > https://lists.nongnu.org/**mailman/listinfo/fab-user<https://lists.nongnu.org/mailman/listinfo/fab-user> >
_______________________________________________ Fab-user mailing list Fab-user@nongnu.org https://lists.nongnu.org/mailman/listinfo/fab-user