gcp_compute_instance_info >> filters

I am trying to implemet filtering based on the tags which my vm has.
unfortunately have not been able to get it to work. Can someone share an example here.

here is my current playbook.

  • name: Locate Instance
    hosts: localhost
    gather_facts: false
    tasks:
  • name: search for google instances
    gcp_compute_instance_info:
    filters:
  • name = webserver
  • tags = webserver

- name = test_object

zone: us-central1-a
project: concise-rampart-288609
auth_kind: serviceaccount
service_account_file: ~/Downloads/concise-rampart-288609-3d94f060ecb5.json
scopes:

I don’t have an answer, but could you please make sure your playbook code is properly indented?
This appears to be the sources of many errors lately.

My Bad, DId not realize the formatting got messed up.
Here is the right format.

- name: Locate Instance
  hosts: localhost
  gather_facts: false
  tasks:
   - name: search for google instances
     gcp_compute_instance_info:
       filters:
#         - tags.items = [webserver]
       - name = webserver
       zone: us-central1-a
       project: {{ gcp_project }}
       auth_kind: serviceaccount
       service_account_file: {{ service_account }}
       scopes:
         - [https://www.googleapis.com/auth/compute](https://www.googleapis.com/auth/compute)
     register: instances

   - name: Add all the retrieved instances ip_address to a dynamic inventory
     add_host: hostname={{ item.networkInterfaces[0].accessConfigs[0].natIP }} groupname=new_instances
     with_items: "{{ instances.resources }}"

     #     -  "{{ disk['resources']['name'] }}"
     #     -  "{{ ansible_facts }}"
     #     -  "{{ gcp_compute_disk_name | select('match', '^(gcp-compute-disk)') | list }}"
     when: instances is defined