我正在尝试获取具有最多可用空间的 VMware 数据存储,然后使用它的 URL 在 Kubernetes 集群中创建存储类。
我正在使用模块获取信息vmware_datastore_info
,如下所示:
---
- name: Gather info from ESXi datacenter
hosts: localhost
gather_facts: false
tasks:
- name: Gather info from ESXi datastore
vmware_datastore_info:
hostname: '{{ vcenter_server }}'
username: '{{ username }}'
password: '{{ password }}'
datacenter_name: '{{ datacenter_name }}'
validate_certs: false
delegate_to: localhost
register: info
- debug: var=info.datastores
示例info.datastores
结果
{
"msg": [
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154511257600,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_078",
"provisioned": 1596981248,
"type": "VMFS",
"uncommitted": 0,
"url": "ds:///vmfs/volumes/64e55997-3946cc08-ce62-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154341388288,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_075",
"provisioned": 11265900544,
"type": "VMFS",
"uncommitted": 9499049984,
"url": "ds:///vmfs/volumes/64e5595d-02d66360-bf73-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154511257600,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_077",
"provisioned": 1596981248,
"type": "VMFS",
"uncommitted": 0,
"url": "ds:///vmfs/volumes/64e55986-d2d1286a-5c00-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154079244288,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_067",
"provisioned": 2943352832,
"type": "VMFS",
"uncommitted": 914358272,
"url": "ds:///vmfs/volumes/60743b62-a519d76c-1d48-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154511257600,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_074",
"provisioned": 1596981248,
"type": "VMFS",
"uncommitted": 0,
"url": "ds:///vmfs/volumes/64e5594a-07107de8-1823-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 5154511257600,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_072",
"provisioned": 1596981248,
"type": "VMFS",
"uncommitted": 0,
"url": "ds:///vmfs/volumes/64e5591a-1ed49f04-2a09-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "DDA_SPIT_013_002",
"freeSpace": 4399479914496,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_071",
"provisioned": 1383218544640,
"type": "VMFS",
"uncommitted": 626590220288,
"url": "ds:///vmfs/volumes/64e558fc-6a916ba4-82d3-9440c96b1102/"
},
{
"accessible": true,
"capacity": 5156108238848,
"datastore_cluster": "CZCHO_SPIT_013_002",
"freeSpace": 3060709457920,
"maintenanceMode": "normal",
"multipleHostAccess": true,
"name": "LIT013_070",
"provisioned": 2428559687680,
"type": "VMFS",
"uncommitted": 333160906752,
"url": "ds:///vmfs/volumes/6346c446-6219e6bc-f0a7-9440c96b1102/"
}
]
}
我怎样才能datastores.url
从这个结果中只得到一个?