# invalid syntax on datastore check

**URL:** <https://forum.ansible.com/t/invalid-syntax-on-datastore-check/37665>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [February 16, 2023, 10:22pm UTC](https://forum.ansible.com/t/invalid-syntax-on-datastore-check/37665 "2023-02-16T22:22:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilkam](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@bilkam](https://forum.ansible.com/u/bilkam)\
**Post date:** [February 16, 2023, 10:22pm UTC](https://forum.ansible.com/t/invalid-syntax-on-datastore-check/37665/1 "2023-02-16T22:22:08Z")

</div>

I’m trying to create a playbook to verifie a space on the datastore before create a VM and I need the creation to faild if datastore usage \> 80 %

My playbook is like the below and I am stuck on The conditional check invalid syntax

Can you please help

- name: Get VM datastore info  
vmware\_datastore\_facts:  
hostname: “{{ vcenter\_server }}”  
username: “{{ vcenter\_user }}”  
password: “{{ vcenter\_pass }}”  
datacenter: “{{data\_center}}”  
validate\_certs: False  
name: “{{ vm\_datastore }}”  
register: datastore  
delegate\_to: localhost

- set\_fact:  
datastore\_capacity: “{{ datastore.datastores[0].capacity }}”  
datastore\_freeSpace: “{{ datastore.datastores[0].freeSpace}}”

- fail:  
msg: “No more space on VMware datastore”  
when:

- ’ (“{{datastore\_freeSpace}}” // “{{datastore\_capacity}}”) \* 100) \> 80’

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [February 17, 2023, 5:24am UTC](https://forum.ansible.com/t/invalid-syntax-on-datastore-check/37665/2 "2023-02-17T05:24:01Z")

</div>

> I’m trying to create a playbook to verifie a space on the datastore before create a VM and I need the creation to faild if datastore usage \> 80 %
> 
> My playbook is like the below and I am stuck on The conditional check invalid syntax
> 
> Can you please help
> 
> - name: Get VM datastore info  
> vmware\_datastore\_facts:  
> hostname: “{{ vcenter\_server }}”  
> username: “{{ vcenter\_user }}”  
> password: “{{ vcenter\_pass }}”  
> datacenter: “{{data\_center}}”  
> validate\_certs: False  
> name: “{{ vm\_datastore }}”  
> register: datastore  
> delegate\_to: localhost
> 
> - set\_fact:  
> datastore\_capacity: “{{ datastore.datastores[0].capacity }}”  
> datastore\_freeSpace: “{{ datastore.datastores[0].freeSpace}}”
> 
> - fail:  
> msg: “No more space on VMware datastore”

Try:

when: (datastore\_freeSpace // datastore\_capacity \* 100) \> 80
