title: Running a playbook on multiple host groups one at a time
body: <p>I want to run a playbook containing some roles on multiple host groups I create dynamically with the group_by module.</p>
  
  <p>I'm able to do it like the example below (ping replacing my actual role).</p>
  
  <p>I was wondering if there is a way to run each group separately in a loop instead of listing all instance ids. I don't want to create a duplicate line with every instance id.</p>
  
  <p>The purpose here is to deploy to one instance in every data center at a time instead of running all with a low serial which takes a long time.</p>
  
  <p>There might be a different way of doing it, I don't want to create static groups in the inventory for each instance_id as well.</p>
  
  <pre><code>---
  - hosts: tag_type_edgenode
    tasks:
      - group_by: key=instance_id_{{instance_id}}
        register: dyn_groups
  
  - hosts: instance_id_1
    tasks:
      - ping:
  - hosts: instance_id_2
    tasks:
      - ping:
  - hosts: instance_id_3
    tasks:
      - ping:
  - hosts: instance_id_4
    tasks:
      - ping:
  </code></pre>