I am trying to develop a Ansible playbook to select and display the list of datastores in vCenter, however for validation purpose I should not select the datastore that contains the local or Local in its name.
For example consider the following 4 datastores:
datastore:local8TQAESXHOST05-Local01vnx_dwcesxbl_ecom_lun7tqaesx37d_1
It should only select:
vnx_dwcesxbl_ecom_lun7tqaesx37d_1
Should not select:
datastore:local8TQAESXHOST05-Local01
Here is the playbook
tasks:
- name: List of datastores with calculated values
set_fact:
ds_size_list: "{{ ds_size_list | default([]) + [{ 'name' : item.name, 'capacity' : item.capacity, 'freeSpace' : item.freeSpace, 'freeSpaceAfter' : freeSpaceAfter | int, 'percentFreeAfter' : percentFreeAfter | int }] }}"
with_items: "{{ datastore_info.datastores }}"
vars:
freeSpaceAfter: "{{ item.freeSpace - (vm_size_b | int) }}"
percentFreeAfter: "{{ freeSpaceAfter | int / item.capacity * 100 }}"
when: item.accessible
when: when: item.name is regex(?!local) #should exclude datastores containing "local" word
Need suggestions on writing the regex expression to exclude the datastores containing the word local.