fetching VMs Info via Anisble

Hi Team

I am trying to fetch different VMs info using vminfo module nd my Yaml looks like below:

===============playbook yaml=============

  • hosts: Web
    gather_facts: false
    become: false
    vars:
    vcenter_hostname: x.x.x.x
    vcenter_username:
    vcenter_password:
    tasks:

  • name: Gather all registered virtual machines
    community.vmware.vmware_vm_info:
    hostname: ‘{{ vcenter_hostname }}’
    username: ‘{{ vcenter_username }}’
    password: ‘{{ vcenter_password }}’
    delegate_to: localhost
    register: vminfo

  • debug:
    msg: “{{ item.guest_name }}, {{ item.ip_address }}”
    with_items:

  • “{{ vminfo.virtual_machines }}”

Hi Team

I am trying to fetch different VMs info using vminfo module nd my Yaml looks like below:

===============playbook yaml=============

  • hosts: Web
    gather_facts: false
    become: false
    vars:
    vcenter_hostname: x.x.x.x
    vcenter_username:
    vcenter_password:
    tasks:

  • name: Gather all registered virtual machines
    community.vmware.vmware_vm_info:
    hostname: ‘{{ vcenter_hostname }}’
    username: ‘{{ vcenter_username }}’
    password: ‘{{ vcenter_password }}’
    delegate_to: localhost
    register: vminfo

  • debug:
    msg: “{{ item.guest_name }}, {{ item.ip_address }}”
    with_items:

  • “{{ vminfo.virtual_machines }}”

=========================================

In the hosts file i have give Vcenter IP details as below:

========Host file==========
[Web]
x.x.x.x #ip of my vcenter server

==============

But while triggering ansible playbook i am getting error as below:

================Error==================

[WARNING]: Could not match supplied host pattern, ignoring: vmware_test.yaml

This is your error.
It indicates that you ‘triggered’ ansible playbook incorrectly. Apparently you supplied a file name as the host pattern.
What are you files called?
And what command do you run?

I recommend you take an ansible class. The class is very worth the time and money. It will help you past these initial hurdles more quickly than asking in online forums. I put over 50 people through it two years ago. Worth every penny.