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 differ
For everyone else ever with this question, here is my solution:
The key was finding env.host_string.
This is how I restart different types of servers with one command:
env.roledefs = {
'apache': ['xxx.xxx.com'],
'APE': ['yyy.xxx.com']
}
def apache():
env.roles = ['apache']
...
def restart():
if env.host_string in env.roledefs['apache']:
sudo("apache2ctl graceful", pty=True)
elif env.host_string in env.roledefs['APE']:
sudo ("supervisorctl reload", pty=True)
enjoy!