[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] Noob not quite understanding roles . . .
From: |
Jeff Forcier |
Subject: |
Re: [Fab-user] Noob not quite understanding roles . . . |
Date: |
Thu, 23 Sep 2010 16:54:31 -0400 |
Hi Brian,
This is a common misconception, though it's more due to Fabric's
simplistic execution model than anything else (and something we'll be
addressing in the future).
Here's a recent explanation of the issue:
http://lists.nongnu.org/archive/html/fab-user/2010-09/msg00008.html
-Jeff
On Thu, Sep 23, 2010 at 4:17 PM, address@hidden
<address@hidden> wrote:
> Hi,
>
> I must not understand the usage of roles. Given:
>
> from fabric.api import *
> from fabric.state import output
> from fabric.decorators import roles
>
> env.hosts =
> ['address@hidden:22','address@hidden:7722','address@hidden','address@hidden']
> env.roledefs = {
> 'deploy':
> ['address@hidden:22','address@hidden:7722','address@hidden'],
> 'stage': ['address@hidden'],
> }
> env.key_filename = '/path/to/known_hosts'
>
> def pack():
> """do some local stuff"""
> print("Executing pack on %(host)s as %(user)s" % env)
>
> @roles('stage')
> def update_staging():
> """update the staging server"""
> print("Executing update_staging on %(host)s as %(user)s" % env)
>
> @roles('deploy')
> def update_production():
> """update the production servers"""
> print("Executing update_production on %(host)s as %(user)s" % env)
>
> def go():
> pack()
> update_staging()
> update_production()
>
>
> I would expect update_staging to only be acted on by the 'stage' roledef and
> the update_production by the 'deploy' roledef.
>
> Any help would be very appreciated:)
>
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
--
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org