title: Ansible select host group dynamically
body: <p>My inventory file looks like below.</p>
  
  <pre><code>[host-group-1]
   x.x.x.1
   x.x.x.2
  
  [host-group-2]
   x.x.x.3
   x.x.x.4
  </code></pre>
  
  <p>Now I want to select and perform tasks on these groups based on the parameter return by a script.
  The playbook looks below.</p>
  
  <pre><code>---
  - host: 127.0.0.1
    tasks:
    - name: something 
      local_action: /home/script.py
      register: result
  
   - host: host-group-1:host-group-2
     task: ?????????
  </code></pre>
  
  <p>Here on the 2nd task I want something like if result== yes perform the task on host-group-1 and if result==no perform the task host-group-2</p>
  
  <p>Please help me here.</p>