[WARNING]: provided hosts list is empty, only localhost is available

4,615 views
Skip to first unread message

Tony Wong

unread,
May 24, 2020, 6:56:49 PM5/24/20
to Ansible Project
---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  vars:
    vm_list:
    - dr-reb
    - dr-wac
    tasks:
    - name: get info about the virtual machine
      vmware_guest_info:
        hostname: vcenter
        username: admini...@vsphere.local
        password: Password123@
        datacenter: RW-VA
        validate_certs: False
        name: "{{ item }}"
        schema: "vsphere"
        properties: ["config.hardware.memoryMB", "config.hardware.numCPU", "guest.disk", "overallStatus"]
      delegate_to: localhost
      register: vm_info
      with_items: "{{ vm_list }}"
    - debug:
        msg: "{{ vm_list }}"


tony@ubuntu:~/ansiblework$
tony@ubuntu:~/ansiblework$
tony@ubuntu:~/ansiblework$
tony@ubuntu:~/ansiblework$
tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml





why is it when i run this pb

I get nothing but this

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

[WARNING]: Found variable using reserved name: tasks

James Cassell

unread,
May 24, 2020, 7:08:54 PM5/24/20
to Ansible List
Delete 2 spaces from the tasks line.

V/r,
James Cassell

Tony Wong

unread,
May 24, 2020, 7:14:25 PM5/24/20
to ansible...@googlegroups.com
Thanks!

but I dont see any output running it


[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAY [get info vm] ******************************************************************************************************************************************************************

TASK [get info about the virtual machine] *******************************************************************************************************************************************
ok: [localhost -> localhost] => (item=dr-reb)
ok: [localhost -> localhost] => (item=dr-wac)

TASK [debug] ************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "dr-reb",
        "dr-wac"
    ]
}

PLAY RECAP **************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e3016f38-6094-4de7-9c52-ececd1b3ac05%40www.fastmail.com.

James Cassell

unread,
May 24, 2020, 7:29:51 PM5/24/20
to Ansible List
Run with -vvv to see all the details of each task.

V/r,
James Cassell

Vladimir Botka

unread,
May 24, 2020, 7:32:52 PM5/24/20
to Tony Wong, ansible...@googlegroups.com
On Sun, 24 May 2020 16:13:56 -0700
Tony Wong <tdub...@gmail.com> wrote:

> [WARNING]: provided hosts list is empty, only localhost is available. Note
> that the implicit localhost does not match 'all'

Run the command below a see what's going on

shell> ansible-inventory -vvv --graph

Tony Wong

unread,
May 25, 2020, 12:27:15 AM5/25/20
to ansible...@googlegroups.com
tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml -vvv
ansible-playbook 2.9.0
  config file = /home/tony/ansiblework/ansible.cfg
  configured module search path = [u'/home/tony/ansiblework/library']
  ansible python module location = /home/tony/.local/lib/python2.7/site-packages/ansible
  executable location = /home/tony/.local/bin/ansible-playbook
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
Using /home/tony/ansiblework/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAYBOOK: vmware_tools.yml *********************************************************************************************************************************************************
1 plays in vmware_tools.yml

PLAY [get info vm] *****************************************************************************************************************************************************************
META: ran handlers


TASK [get info about the virtual machine] ******************************************************************************************************************************************
task path: /home/tony/ansiblework/vmware_tools.yml:11
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: tony
<localhost> EXEC /bin/sh -c 'echo ~tony && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055 `" && echo ansible-tmp-1590380567.97-36211623708055="` echo /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055 `" ) && sleep 0'
Using module file /home/tony/.local/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest_info.py
<localhost> PUT /home/tony/.ansible/tmp/ansible-local-13810s8NNqR/tmpZCfPWw TO /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055/AnsiballZ_vmware_guest_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055/ /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055/AnsiballZ_vmware_guest_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055/AnsiballZ_vmware_guest_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1590380567.97-36211623708055/ > /dev/null 2>&1 && sleep 0'
ok: [localhost -> localhost] => (item=dr-reb) => {
    "ansible_loop_var": "item",
    "changed": false,
    "instance": {
        "config": {
            "hardware": {
                "memoryMB": 8192,
                "numCPU": 4
            }
        },
        "guest": {
            "disk": [
                {
                    "_vimtype": "vim.vm.GuestInfo.DiskInfo",
                    "capacity": 75159826432,
                    "diskPath": "C:\\",
                    "freeSpace": 12846444544
                },
                {
                    "_vimtype": "vim.vm.GuestInfo.DiskInfo",
                    "capacity": 32209104896,
                    "diskPath": "D:\\",
                    "freeSpace": 8619995136
                }
            ]
        },
        "overallStatus": "green"
    },
    "invocation": {
        "module_args": {
            "datacenter": "RW-VA",
            "folder": null,
            "hostname": "vasvw-vcsa.",
            "moid": null,
            "name": "dr-reb",
            "name_match": "first",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,

            "properties": [
                "config.hardware.memoryMB",
                "config.hardware.numCPU",
                "guest.disk",
                "overallStatus"
            ],
            "proxy_host": null,
            "proxy_port": null,
            "schema": "vsphere",
            "tags": false,
            "use_instance_uuid": false,
            "username": "admini...@vsphere.local",
            "uuid": null,
            "validate_certs": false
        }
    },
    "item": "dr-reb"
}
<localhost> EXEC /bin/sh -c 'echo ~tony && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443 `" && echo ansible-tmp-1590380569.92-7854716787443="` echo /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443 `" ) && sleep 0'
Using module file /home/tony/.local/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest_info.py
<localhost> PUT /home/tony/.ansible/tmp/ansible-local-13810s8NNqR/tmpp4DUr9 TO /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443/AnsiballZ_vmware_guest_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443/ /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443/AnsiballZ_vmware_guest_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443/AnsiballZ_vmware_guest_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1590380569.92-7854716787443/ > /dev/null 2>&1 && sleep 0'
ok: [localhost -> localhost] => (item=dr-wac) => {
    "ansible_loop_var": "item",
    "changed": false,
    "instance": {
        "config": {
            "hardware": {
                "memoryMB": 4096,
                "numCPU": 2
            }
        },
        "guest": {
            "disk": [
                {
                    "_vimtype": "vim.vm.GuestInfo.DiskInfo",
                    "capacity": 42946523136,
                    "diskPath": "D:\\",
                    "freeSpace": 34454917120
                },
                {
                    "_vimtype": "vim.vm.GuestInfo.DiskInfo",
                    "capacity": 107266174976,
                    "diskPath": "C:\\",
                    "freeSpace": 20929310720
                }
            ]
        },
        "overallStatus": "green"
    },
    "invocation": {
        "module_args": {
            "datacenter": "RW-VA",
            "folder": null,
            "hostname": "vasvw-vcsa.",
            "moid": null,
            "name": "dr-wac",
            "name_match": "first",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,

            "properties": [
                "config.hardware.memoryMB",
                "config.hardware.numCPU",
                "guest.disk",
                "overallStatus"
            ],
            "proxy_host": null,
            "proxy_port": null,
            "schema": "vsphere",
            "tags": false,
            "use_instance_uuid": false,
            "username": "admini...@vsphere.local",
            "uuid": null,
            "validate_certs": false
        }
    },
    "item": "dr-wac"
}

TASK [debug] ***********************************************************************************************************************************************************************
task path: /home/tony/ansiblework/vmware_tools.yml:24

ok: [localhost] => {
    "msg": [
        "dr-reb",
        "dr-wac"
    ]
}
META: ran handlers
META: ran handlers

PLAY RECAP *************************************************************************************************************************************************************************

localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0





Why do i need to run it wiht -vvv?

should my playbook show me the output?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

David Foley

unread,
May 25, 2020, 2:16:55 AM5/25/20
to Ansible Project
It's outputting your items list, as you have msg on the list if you are looking to put the info you need to use a register then either var or message that register

Tony Wong

unread,
May 25, 2020, 9:04:11 AM5/25/20
to ansible...@googlegroups.com
what line am i missing to output the information? without using -vvvv

On Sun, May 24, 2020 at 11:17 PM David Foley <david...@mycit.ie> wrote:
It's outputting your items list, as you have msg on the list if you are looking to put the info you need to use a register then either var or message that register

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

Tej Singh Rana

unread,
May 25, 2020, 9:12:28 AM5/25/20
to ansible...@googlegroups.com
You have to use register  module and get that output from debug module.

Reply all
Reply to author
Forward
0 new messages