On Thu, 16 Feb 2023 at 23:22, [email protected] <[email protected]>
wrote:

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


-- 
> 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/a89f4431-2ba1-4b42-98b3-83f650e2ea3cn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a89f4431-2ba1-4b42-98b3-83f650e2ea3cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Sent from Gmail Mobile

-- 
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/CAF8BbLZtRhWnXw1WHqdL%3DBOmo17iveM8voM4O_BVgW2MNc%3DjSw%40mail.gmail.com.

Reply via email to