Matt,

Thank you for the reply. I failed to mention what I've tried before.

So, I tried what you suggested and I got more or less the same error 
message. I've also tried the following:

 

disks[].licenses[]:ubuntu

disks.licenses=ubuntu

disks[].licenses[]=ubuntu

 
I've also referred to their examples page before but it seems insufficient 
for comparing arrays of data. Another interesting thing (that may or may 
not be worth noting) is that when I run my inventory file and try to use 
machineType as a filter, it actually filters off of `machineType_selflink` 
instead.

On Wednesday, January 30, 2019 at 11:43:16 AM UTC-7, Matt Martz wrote:
>
> Reading 
> https://cloud.google.com/compute/docs/reference/rest/v1/instances/list
>
> It seems `filters` should look like:
>
> `scheduling.automaticRestart = false`
>
> So I think you want:
>
> ```
> filters: 
>   - disks.licenses = ubuntu
> ```
>
> There are examples on the gcp_compute inventory plugin page at: 
> https://docs.ansible.com/ansible/latest/plugins/inventory/gcp_compute.html#examples
>
> On Wed, Jan 30, 2019 at 12:38 PM <zach....@multiscalehn.com <javascript:>> 
> wrote:
>
>> I'm trying to get a list of Ubuntu instances from a GCE project. This is 
>> what my inventory file looks like.
>>
>> plugin: gcp_compute
>> projects:
>>  - <project-name>
>> filters: 
>>   - disks.licenses:ubuntu
>> auth_kind: serviceaccount
>> service_account_file: ~/google_cloud/service_account/key/<filename>.json
>>
>>
>> I have referred to this page for the gcp_compute plugin: 
>> https://docs.ansible.com/ansible/latest/plugins/inventory/gcp_compute.html
>> And when it refers to filters, the documentation links to this page: 
>> https://cloud.google.com/compute/docs/reference/rest/v1/instances/list
>>
>> When I run:
>> gcloud compute instances list --filter="(disks.licenses:ubuntu)" --format
>> =json
>> ... it works just fine and only returns Ubuntu instances.
>>
>> However, running
>> ansible-inventory -i <filename>.gcp.yml --list
>> ... with the "disks.licenses:ubuntu:" filter returns the following:
>>
>> *[WARNING]:  * Failed to parse 
>> /Users/username/.ansible/inventory/<filename>.gcp.yml with yaml plugin: 
>> Plugin configuration YAML file, not YAML inventory*
>>
>> * [WARNING]:  * Failed to parse 
>> /Users/username/.ansible/inventory/<filename>.gcp.yml with ini plugin:*
>>
>> */Users/username/.ansible/inventory/<filename>.gcp.yml:1: Expected 
>> key=value host variable assignment, got: gcp_compute*
>>
>> * [WARNING]:  * Failed to parse 
>> /Users/username/.ansible/inventory/<filename>.gcp.yml with auto plugin: 
>> [{'domain': 'global', 'reason': 'invalid',*
>>
>> *'message': "Invalid value for field 'filter': 'disks.licenses:ubuntu'. 
>> Invalid list filter expression."}]*
>>
>> * [WARNING]: Unable to parse 
>> /Users/username/.ansible/inventory/<filename>.gcp.yml as an inventory 
>> source*
>>
>> * [WARNING]: No inventory was parsed, only implicit localhost is 
>> available*
>>
>>
>> {
>>
>>    "_meta": {
>>
>>        "hostvars": {}
>>
>>    },
>>
>>    "all": {
>>
>>        "children": [
>>
>>            "ungrouped"
>>
>>        ]
>>
>>    },
>>
>>    "ungrouped": {}
>>
>> }
>>
>> Has anyone been able to resolve this sort of issue before? If so, what 
>> did you do?
>>
>> -- 
>> 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 <javascript:>.
>> To post to this group, send email to ansible...@googlegroups.com 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/4a1f507c-68ae-4914-912f-7d46e42fff4c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/4a1f507c-68ae-4914-912f-7d46e42fff4c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cd9932da-17d3-44e4-b1a8-ef29c90114c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to