fab-user
[Top][All Lists]
Advanced

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

[Fab-user] using value of env.host


From: Simon Smith
Subject: [Fab-user] using value of env.host
Date: Tue, 6 Oct 2009 19:12:54 -0400

How would I access the value of host in a fab function?

What I want to do is something like

fab my_fab_command:host=webserver3

contents of fabfile.py:

def load_special_hosts():
  (yes, I would normally put this in another file and import it)
  (some code that accesses an external resource to populate special_hostlist)
  return special_hostlist

def my_fab_command():
     speciallist = load_special_hosts()
     if speciallist.count(env.host):
         do-something-special
     else:
         do-the-normal-thing


But since env.host (or env.hosts) are gone (taken out when
parse_arguments is called, right?), I don't know how to get at
env.host (or its equivalent)

I looked around the documentation and can't find the way (if there is
a way) to access env.host

Obviously, I could put my if-then logic in another script, and then
have that script call "fab" with different inputs, but I would like to
have the logic in my fab functions.

Thanks,

Simon Smith
Arcode Corporation




reply via email to

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