title: Ansible: Conditional check to either output name of child group or individual host based on specified limit
body: <p>Hi to all friendly automagicians,</p>
  
  <p>I'm using ansible in order to administrate tasks on a heap of embedded linux nodes that are rapidly expanding. Since our project is using hipchat, I figured it's necessary to start notifying to a room so I don't keep annoying researchers by rebooting or something when working on a node.</p>
  
  <p>I have divided the hosts inventory up into child groups based on their switch ports and vlans. 
  So when I want to do something to all production, I don't use use the limit option.. 
  When I want to do something to a specific chain of nodes, I limit to a child group.. and when I want to do something individually I limit to the hostname.</p>
  
  <p>So I am using a notify at the end of a task to post to hipchat like so:</p>
  
  <pre><code>- name: "Notify hipchat" 
      hipchat_v2:
        msg='{{ inventory_hostname }} was updated from {{ version.stdout }} to {{ newversion.stdout }}'
  </code></pre>
  
  <p>The problem is when I go to do an action like system wide updates in batches of child groups it's going result in a message for each node to the room which will mean hundreds over a couple of hours, so in this case I'd rather output the name of the child group.</p>
  
  <p>However I still want to maintain the ability to notify room of the same action performed on an individual host.</p>
  
  <p>That's where my question comes in:</p>
  
  <p>Is there a way I can configure the playbook to use a conditional test in order to output an individual host name if the action is limited to a single host name like I'm doing with {{ inventory hostname }}, yet only output the name of the child group if the action is limited to a child group instead?</p>
  
  <p>So in a logical flow (<strong>yes I know this isn't real code - just code logic</strong>), something like:</p>
  
  <pre><code>If --limit option = group
  then print group
  elif --limit option = group:research-nodes
  then print research-nodes
  elif --limit option = individual host
  then print hostname
  fi
  </code></pre>