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


On Mon, Sep 21, 2020 at 8:26 PM Dick Visser <[email protected]> wrote:

> 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.
>
> On Mon, 21 Sep 2020 at 15:08, Yantram Cloud <[email protected]>
> wrote:
>
>> 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:
>> - https://www.googleapis.com/auth/compute
>> register: instances
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/904af85e-17bb-4975-92a7-ad60eeac9c68n%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/904af85e-17bb-4975-92a7-ad60eeac9c68n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/2Y5orHeAH40/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNmpb8D28Fdvn5i2a%2BL7ZmVByg5pYgyUVvi_-7VW3EpRQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNmpb8D28Fdvn5i2a%2BL7ZmVByg5pYgyUVvi_-7VW3EpRQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ4U50V57hisgADgZVAbB%3Dbm6%2B58u4x2QmAhmG6z6ZfmKwxUtg%40mail.gmail.com.

Reply via email to