title: Ansible. How to choose N hosts from group
body: <p>Assume that a group has 10 hosts.<br>
  How to run playbook on N hosts from 10. N is arbitrary value from 1 to 10.<br>
  Example:</p>
  
  <pre><code>- hosts: groups['group_name'][1:3] it works.
  </code></pre>
  
  <p>But it doesn't work if instead of 3 I use variable, like this</p>
  
  <pre><code>- hosts: groups['group_name'][1:N]  
  </code></pre>
  
  <p>It could be random N, first N, last N what ever.  </p>
  
  <p>Thank you.</p>