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