title: Configure Ansible roles with dependent roles
body: <p>The problem is best described with an example:</p>
  
  <p>There are two roles:</p>
  
  <ul>
  <li><code>mailserver</code>: a basic mail server configuration</li>
  <li><code>mailinglist</code>: mailing list application</li>
  </ul>
  
  <p>The mailing list software needs the mailserver to transport incoming mails to the mailing list software's "virtual inbox". This requires some configuration of the mail server. But the mailserver does not know about the mailing list role, nor other roles with similar configuration requirements.</p>
  
  <p>What I would like to do is this:</p>
  
  <ul>
  <li><code>mailinglist</code> (and other similar roles) stores the transport configuration in a variable <code>transport_config</code>. This could be a "transport map" like $email => $spool.</li>
  <li><code>mailinglist</code> depends on the <code>mailserver</code> role.</li>
  <li><code>mailserver</code> configures it's "transport" using the variable <code>transport_config</code>.</li>
  </ul>
  
  <p>Is there a way to do something like this in Ansible? Or another solution to this problem? It's <em>not</em> possible to use role variables like <code>{role: mailserver, transport_config: ...}</code>, as there may be more than one role depending on the mailserver.</p>
  
  <p>What I can think of is a workaround: The mailserver reads/parses a configuration directory where transport maps are defined. <code>mailinglist</code> and other roles add files to this directory. The problem here is that this often requires a "configuration builder" which reads such configuration directories and generates the main configuration file.</p>