bilkam
1
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’
dnmvisser
(Dick Visser)
2
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