I am trying to filter out the list of VMs with specific tags. The sample playbook is as follows :
- hosts: localhost
gather_facts: false
become: false
vars:
vcenter_hostname: vcenter3423
vcenter_username: center\user4325
vcenter_password: L0gM3In4325
tasks:
- name: Gather all registered virtual machines
community.vmware.vmware_vm_info:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
delegate_to: localhost
register: vminfo
- debug:
msg: "{{ item.guest_name }}, {{ item.ip_address }}, {{ item.guest_fullname }}, {{ item.datacenter }}, {{ item.power_state }}, {{ item.tags }} "
with_items:
- "{{ vminfo.virtual_machines }} | community.general.json_query(query) }}"
vars:
query: "[?guest_name=='CMCUAT']"
However, whatever combination I may try the tags[] output, the rest of the o/p is populated. Not sure what I am missing