title: Sanity check before running ansible playbook -> count hosts
body: <p>I have a playbook that will setup a redis cluster and <a href="https://github.com/twitter/twemproxy">nutcracker</a> as a proxy. Which hosts play which roles is defined per groups. I'd like to add a sanity check in front of running the tasks, that is:</p>
  
  <ul>
  <li>Is there exactly one proxy? (1 host in group A)</li>
  <li>Is there at least one redis node (>=1 host in group B)</li>
  </ul>
  
  <p>I already have a solution, though I think it's pretty ugly and thought there has to be something better, but I just can't find it. I currently run a local task calling the playbook again with the --list-hosts parameter and check the output.</p>
  
  <pre><code>  - name: Make sure there is only one proxy defined
      shell: ansible-playbook -i {{ inventory_file }} redis-cluster.yml --tags "redis-proxy" --list-hosts
      register: test
      failed_when: test.stdout.find("host count=1\n") == -1
      changed_when: 1 == 2
  </code></pre>
  
  <p>That works but isn't there a simply way to check the number of hosts in a group without this extra call?</p>