title: How to make Ansible playbook run on first host in the group?
body: <p>How can I run a playbook only on first host in the group?</p>
  
  <p>I am expecting something like this:</p>
  
  <pre><code>---
  - name: playbook that only run on first host in the group
    hosts: "{{ groups[group_name] | first }}"
  
    tasks:
     - debug:
         msg: "on {{ inventory_hostname }}"
  </code></pre>
  
  <p>But this doesn't work, gives error:</p>
  
  <blockquote>
    <p>'groups' is undefined</p>
  </blockquote>
  
  <p>How can I make it work?</p>