# issue with running inventory with gcp\_compute plugin filters

**URL:** <https://forum.ansible.com/t/issue-with-running-inventory-with-gcp-compute-plugin-filters/29573>\
**Category:** Ansible Project\
**Tags:** gcp, ubuntu\
**Created:** [January 30, 2019, 6:38pm UTC](https://forum.ansible.com/t/issue-with-running-inventory-with-gcp-compute-plugin-filters/29573 "2019-01-30T18:38:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zach.delano](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zach.delano](https://forum.ansible.com/u/zach.delano)\
**Post date:** [January 30, 2019, 6:38pm UTC](https://forum.ansible.com/t/issue-with-running-inventory-with-gcp-compute-plugin-filters/29573/1 "2019-01-30T18:38:51Z")

</div>

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:
> 
> - 
> 
> filters:
> 
> - disks.licenses:ubuntu  
> auth\_kind: serviceaccount  
> service\_account\_file: ~/google\_cloud/service\_account/key/.json

I have referred to this page for the gcp\_compute plugin: [https://docs.ansible.com/ansible/latest/plugins/inventory/gcp\_compute.html](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](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 .gcp.yml --list

`  
… with the “disks.licenses:ubuntu:” filter returns the following:

`

**[WARNING]: \* Failed to parse /Users/username/.ansible/inventory/.gcp.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory**

**[WARNING]: \* Failed to parse /Users/username/.ansible/inventory/.gcp.yml with ini plugin:**

**/Users/username/.ansible/inventory/.gcp.yml:1: Expected key=value host variable assignment, got: gcp\_compute**

**[WARNING]: \* Failed to parse /Users/username/.ansible/inventory/.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/.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?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 30, 2019, 6:42pm UTC](https://forum.ansible.com/t/issue-with-running-inventory-with-gcp-compute-plugin-filters/29573/2 "2019-01-30T18:42:31Z")

</div>

Reading [https://cloud.google.com/compute/docs/reference/rest/v1/instances/list](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:

```auto

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](https://docs.ansible.com/ansible/latest/plugins/inventory/gcp_compute.html#examples)

---

<div class="post-metadata">

**Author:** ![zach.delano](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zach.delano](https://forum.ansible.com/u/zach.delano)\
**Post date:** [January 30, 2019, 6:53pm UTC](https://forum.ansible.com/t/issue-with-running-inventory-with-gcp-compute-plugin-filters/29573/3 "2019-01-30T18:53:59Z")

</div>

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.
