Re: [Fab-user] Can Fabric have (simple) multi-server wrapper tasks?

2011-02-03 Thread Daniel Pope

On 02/02/11 23:48, Jeff Forcier wrote:

 def deploy():
 execute(update_django_project)
 execute(update_db)
 execute(update_services)


Ew :-P


Point being that in order to get the extra magic of honoring
host/role decorators, we'd need to ask users to move from calling
subtasks directly, to passing them into some new API function call.
Not quite as simple, but much more powerful.


I wrote @default_role, @default_hosts decorators that supply a host list 
if there is none, no matter how the function is called. So it is 
possible to write the straightforward


def deploy():
update_django_project()
update_db()
update_services()

to operate on the appropriate roles so long as you don't call deploy() 
with any hosts.


There were three use cases for these tasks that needed to work, eg.

1. fab deploy
2. fab update_django_project update_db
3. fab -H web1 update_django_project

In fact my implementation operated on roles and other facts stored in 
external YAML, as I described here:


http://lists.nongnu.org/archive/html/fab-user/2010-12/msg00020.html

Dan
--
Mauve Internet
t: 01243 888187
w: www.mauveinternet.co.uk

___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user


RE: [Fab-user] Can Fabric have (simple) multi-server wrapper tasks?

2011-02-02 Thread Daniel Craig
I think what Carlton is looking for is a little different, though I do like 
your method.   I think I have the same needs as Carlton.  Likewise, I'm running 
a Django project with multiple servers acting in different roles.  Fabric's 
roles are great to handle that.  So I currently have something like this:

def production():
env.roledefs['httpd'] = 'mywebserver.example.com'
env.roledefs['db'] = 'mydbserver.example.com'
env.roledefs['otherservices'] = 'otherservices.example.com'

@roles(['httpd'])
def update_django_project():
run('my_update_routine...')

@roles(['db'])
def update_db():
run('my_db_actions...')

@roles(['otherservices'])
def update_services():
run('my_services_stuff...')


Right now, I have to run these sequentially from the command prompt, since the 
decorators don't seem to work within another method.

$ fab production update_django_project
$ fab production update_db
$ fab production update_services

What I'd love, and I suspect Carlton would as well, is the ability to wrap all 
those up in a single function

def deploy():
update_django_project()
update_db()
update_services()

And thus be able to deploy with one line

$ fab production deploy

- Dan
___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user