fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] order control


From: Jeff Forcier
Subject: Re: [Fab-user] order control
Date: Thu, 14 Oct 2010 10:08:44 -0400

Hi Jeff,

Morgan is right, the merging process roles/hosts go through, dedupes
them via set() which is an unordered collection data type. Thus, order
is not always preserved.

This has come up once or twice before but there didn't seem to be any
record of it, so I just jotted down the problems here:

    http://code.fabfile.org/issues/show/243

The tl;dr is that because the host list a task runs on is drawn from
many different sources, there may be no way to have a truly intuitive
ordering that isn't going to trip up users.

If order really matters, you can avoid Fabric's built-in (and right
now, simplistic) task runner by dropping the @roles and iterating over
the role definition inside your task instead, setting the host_string
setting:

    def putfile():
        for host in env.roledefs['servers']:
            with settings(host_string=host):
                put(blah)
                run(blah)
                [...]

See this link for a more in depth explanation of how all this stuff works:

    http://docs.fabfile.org/0.9.2/usage/execution.html#connections

(See the rest of that document for even more details, if you want.)

This particular approach will be made easier in the near future,
something like execute(task_function, host_list) so you won't even
need to do your own for/with combo.

Best,
Jeff

On Thu, Oct 14, 2010 at 9:43 AM, Jeff Honey <address@hidden> wrote:
> <snip>
> from fabric.api import *
>
> env.hosts = ['foo1.com', 'foo2.com', 'foo3.com', 'foo4.com', 'foo5.com', 
> 'foo6.com']
>
> def putfile():
>  put(r'c:\blah.txt', '/tmp/')
>  run('touch /tmp/blah.txt')
> </snip>
>
> I checked and double-checked that there were no dupes in my list. Previously 
> it was using this:
>
> <snip>
> from fabric.api import *
>
> env.roledefs = {
>    'servers': ['foo1.com', 'foo2.com', 'foo3.com', 'foo4.com', 'foo5.com', 
> 'foo6.com'],
>    }
>
> @roles('servers')
> def putfile():
>  put(r'c:\blah.txt', '/tmp/')
>  run('touch /tmp/blah.txt')
> </snip>
>
> ...the behaviour I was expecting was for the function 'pufile()' to happen on 
> foo1.com first and then go through the rest of the list in order.
> --
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> ¤ kyoboku kazeoshi ¤
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> ________________________________________
> From: Morgan Goose address@hidden
> Sent: Thursday, October 14, 2010 9:26
> To: Jeff Honey
> Subject: Re: [Fab-user] order control
>
> If I recall the hosts all get sent through a set() conversion to remove
> duplicates, that would make the order undefined. Do you have an example 
> fabfile
> we can look at?
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org



reply via email to

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