Hi
This is a very Fabric specific question, but more experienced python hackers might be able to answer this, even if they don't know Fabric.
I am trying to specify different behaviour in a command depending on which role it is running for, i.e.:
def restart():
if (SERVERTYPE == "APACHE"):
sudo("apache2ctl graceful",pty=True)
elif (SERVERTYPE == "APE"):
sudo("supervisorctl reload",pty=True)
I was hacking this with functions like this one:
def apache():
global SERVERTYPE
SERVERTYPE = "APACHE"
env.hosts = ['xxx.xxx.com']
But that is obviously not very elegant and I just discovered roles, so my question is:
How do I figure out which role a current instance belongs to?
env.roledefs = {
'apache': ['xxx.xxx.com'],
'APE': ['yyy.xxx.com'],
}
Thanks!