fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] env.hosts vs env.host_string


From: Jeff Forcier
Subject: Re: [Fab-user] env.hosts vs env.host_string
Date: Sat, 7 Nov 2009 10:24:07 -0500

You mean...these docs...linked to in the "Documentation" section on
the main page? :D

    http://docs.fabfile.org/0.9/usage/execution.html

Let me know if that page is still unclear in any way :)

-Jeff

On Wed, Nov 4, 2009 at 9:46 PM, Christopher DeMarco <address@hidden> wrote:
> So I think I understand why Fabric works this way, and I'd like to
> see the docs updated for the next poor sap who tries to be clever like
> me :-)
>
> Given the following fabfile:
>
>    from fabric.api import *
>    env.hosts = ['hostA']
>
>    def withEnv():
>        run('/bin/true')
>
>    def paramNo(hostname):
>        env.hosts = [hostname]
>        run('/bin/true')
>
>    def paramYes(hostname):
>        env.host_string = hostname
>        run('/bin/true')
>
>
> Why does paramNo not do what I expect?  (fab output trimmed:)
>
>    $ fab withEnv
>    [hostA] run: /bin/true
>
>    $ fab paramNo:hostB
>    [hostA] run: /bin/true
>
>    $ fab paramYes:hostB
>    [hostB] run: /bin/true
>
>
> I think that the answer is that Fabric loops over env.hosts, setting
> env.host_string inside the invoked function.  Assigning to hosts.env
> within a function will have no effect on where put(), run()
> et.al. runs (but possibly upon subsequent turns of the loop?) since
> env.host_string is already set.  Am I understanding correctly?  Can I
> contribute a simple patch to the docs without monkeying around with
> git?
>
> Fabric is awesome, thanks!
>
>
> --
> Christopher DeMarco <address@hidden>
> IT Director
> MAYA Group
> +1-412-708-9660
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

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