Error when running included playbook

18 views
Skip to first unread message

Larry Bakun

unread,
Dec 4, 2017, 2:44:14 PM12/4/17
to Ansible Project
Hi everyone,
I'm receiving this weird error when running the second playbook (with include module and passing IP address).
Here is my first playbook:

---
- 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 }}"

This first playbook connects to ESXi servers and gets all VMs there, then passes an IP to another playbook where I want to print out my custom facts that I've saved there in the /etc/ansible/facts.d/vmware.facts file.


Here is my second playbook:

  - name: <<Check the IP received
    debug:
      msg: "Received IP: {{ ip_address }}"

  - name: <<Get custom facts
    vmware_vm_facts:
      hostname: "{{ ip_address }}"
      username: root
      password: passw
      validate_certs: False
    delegate_to: localhost
    register: custom_facts

I'm receiving this error not sure why:

TASK [Passing data to include file] ********************************************************************************

task path: /var/lib/awx/projects/loadVCenterInventory/vmware_vm_facts1.yml:22

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55

included: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml for 192.168.1.55


TASK [<<Check the IPS] *********************************************************************************************

task path: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml:3

ok: [192.168.1.55] => {

    "msg": "Received IP: 192.168.1.59"

}


TASK [<<Get custom facts] ******************************************************************************************

task path: /var/lib/awx/projects/loadVCenterInventory/includeFile.yml:7

Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_vm_facts.py

<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root

<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'

<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886 `" && echo ansible-tmp-1512415750.71-126408181937886="` echo /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886 `" ) && sleep 0'

<localhost> PUT /tmp/tmp8miEQJ TO /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py

<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/ /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py && sleep 0'

<localhost> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/" > /dev/null 2>&1 && sleep 0'

fatal: [192.168.1.55 -> localhost]: FAILED! => {

    "changed": false, 

    "failed": true, 

    "invocation": {

        "module_args": {

            "hostname": "192.168.1.59", 

            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 

            "username": "root", 

            "validate_certs": false

        }

    }, 

    "msg": "[Errno 111] Connection refused"

}



 Anybody has any idea?

Thanks,
Larry


Reply all
Reply to author
Forward
0 new messages