[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fab-user] env.hosts vs env.host_string
From: |
Christopher DeMarco |
Subject: |
[Fab-user] env.hosts vs env.host_string |
Date: |
Wed, 4 Nov 2009 21:46:27 -0500 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
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] env.hosts vs env.host_string,
Christopher DeMarco <=