title: How to switch Ansible playbook to another host when calling second playbook
body: <p>I have two playbooks - my first playbook iterates on the list of ESXi servers getting list of all VMs, and then passes that list to the second playbook, that should iterates on the IPs of the VMs. Instead it is still trying to execute on the last ESXi server. I have to switch host to that VM IP that I'm currently passing to the second playbook. Don't know how to switch... Anybody?</p>
  
  <p>First playbook:</p>
  
  <pre><code>- name: get VM list from ESXi
    hosts: all
  
    tasks:
    - name: get facts
      vmware_vm_facts:
        hostname: "{{ inventory_hostname }}"
        username: "{{ ansible_ssh_user }}"
        password: "{{ ansible_ssh_pass }}"
      delegate_to: localhost
      register: esx_facts
  
    - name: Debugging data
      debug:
        msg: "IP of {{ item.key }} is {{ item.value.ip_address }} and is {{ item.value.power_state }}"
      with_dict: "{{ esx_facts.virtual_machines }}"
  
    - name: Passing data to include file
      include: includeFile.yml ip_address="{{ item.value.ip_address }}"
      with_dict: "{{ esx_facts.virtual_machines }}"
  </code></pre>
  
  <p>My second playbook:</p>
  
  <pre><code>- name: &lt;&lt;Check the IP received
    debug:
      msg: "Received IP: {{ ip_address }}"
  
  - name: &lt;&lt;Get custom facts
    vmware_vm_facts:
      hostname: "{{ ip_address }}"
      username: root
      password: passw
      validate_certs: False
    delegate_to: localhost
    register: custom_facts
  </code></pre>
  
  <p>I do receive the correct VM's ip_address but vmware_vm_facts is still trying to run on the ESXi server instead...</p>