title: How can I resolve an inventory member who has a certain attribute?
body: <p>I need to pass a specific host from my inventory as a parameter into a role. The host is part of a group but is demarcated by a variable that none of the other hosts have.</p>
  
  <p>snippet of: hosts.yml</p>
  
  <pre><code>  dbservers:
         hosts:
          pg01:
           ansible_host: pg01.domain.com
           master_slave: master
          pg02:
           ansible_host: pg02.domain.com
           master_slave: slave
  </code></pre>
  
  <p>I want to be able to resolve pg01 based on the fact that the variable master_slave is set to 'master' such that I can call into a role like this:</p>
  
  <pre><code>      - name: Do something
          include_role:
           name: a.database.role.to.run.on.master
          vars:
            master_database_host: {{ something that resolves to pg01 }}
  </code></pre>
  
  <p>How can I resolve the appropriate host from inventory?</p>