Я планирую позвонить vRA api по ansible недавно.Я могу получить результат json, возвращаемый из API, используя режим uriно как я могу получить «перезагрузить машину».Значение id ("07831a32-0bc7-4f7d-8372-164ea69d61af") перед отправкой запроса в API.
логика здесь - сначала элемент содержимого цикла, затем сохраните id.value ("07831a32-0bc7-4f7d-8372-164ea69d61af"), чтобы зарегистрироваться при совпадении ключевых слов (перезагрузить компьютер)
Однако код не работает, как я ожидаю.
Может кто-нибудь помочь мне дать мне совет.как бороться с этим вопросом.
- name: get actions list
uri: xxxxxxx
......
register: actions
- name: var_aaa
when: actions.json.content[{{ item }}]['description'] == "Delete a snapshot of this machine."
with_sequence: start=0 end={{ (actions.json.content|count) -1 }}
register: actions.json.content[{{ item }}]['id']
вот пример json
/
"json": {
"content": [
{
"@type": "ConsumerResourceOperation",
"bindingId": null,
"description": "Infrastructure connect using VMRC",
"extensionId": "csp.places.iaas.item.nowindow.ConnectViaNativeVmrc",
"formScale": null,
"hasForm": false,
"iconId": "cafe_default_icon_genericResourceOperation",
"id": "b0f8dd39-4f69-47c9-8344-5b2fce37cab5",
"name": "Connect using VMRC",
"providerTypeId": null,
"type": "EXTENSION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Virtual.Action.DeleteSnapshot",
"description": "Delete a snapshot of this machine.",
"extensionId": null,
"formScale": "SMALL",
"hasForm": true,
"iconId": "virtualDeleteSnapshot.png",
"id": "6493a45c-4216-4a03-a866-b1ec0636288a",
"name": "Delete Snapshot",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Virtual.Action.Destroy",
"description": "Destroy a virtual machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "virtualDestroy.png",
"id": "6f3f00cc-96e7-4c18-92a6-cdf75236b58a",
"name": "Destroy",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Expire",
"description": "Expire a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineExpire.png",
"id": "a077d4d5-9c2e-45a6-a8c6-2eb42a56de28",
"name": "Expire",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.InstallTools",
"description": "Install tools on a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineInstallTools.png",
"id": "7ed95871-d73b-40ba-8c81-7407ef5e4fa1",
"name": "Install Tools",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Reset",
"description": "Reset a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineReset.png",
"id": "b236c593-e0ee-4676-95ed-52ae4b2c2519",
"name": "Power Cycle",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.PowerOff",
"description": "Power off a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machinePowerOff.png",
"id": "07831a32-0bc7-4f7d-8372-164ea69d61af",
"name": "Power Off",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Reboot",
"description": "Reboot a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineReboot.png",
"id": "bab814c5-6b3c-43cf-8ce2-cd04372d526e",
"name": "Reboot",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Reconfigure",
"description": "Reconfigure a machine.",
"extensionId": null,
"formScale": "BIG",
"hasForm": true,
"iconId": "machineReconfigure.png",
"id": "649522a2-f9e3-4286-ad51-f35eb73b6548",
"name": "Reconfigure",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Reprovision",
"description": "Reprovision a machine.",
"extensionId": null,
"formScale": "BIG",
"hasForm": true,
"iconId": "machineReprovision.png",
"id": "a19b6255-a6e6-4821-a5a0-bfcb5179bd0e",
"name": "Reprovision",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Virtual.Action.RevertSnapshot",
"description": "Revert to a snapshot of this machine.",
"extensionId": null,
"formScale": "SMALL",
"hasForm": true,
"iconId": "virtualRevertSnapshot.png",
"id": "64936231-171f-4e32-99cb-57e872d892ee",
"name": "Revert To Snapshot",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "ycommerce!::!6cbbd9d5-eebe-4b59-b794-08285f9ff5f9",
"description": "Run puppet on one only Virtual Machine other than a HDBC.",
"extensionId": null,
"formScale": "BIG",
"hasForm": true,
"iconId": "298480d7-b094-4580-a703-e4212429656d",
"id": "298480d7-b094-4580-a703-e4212429656d",
"name": "Run Puppet on VM",
"providerTypeId": "com.vmware.csp.core.designer.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Shutdown",
"description": "Shutdown a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineShutdown.png",
"id": "993ae711-88b9-4baa-9678-4cde5694a703",
"name": "Shutdown",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
},
{
"@type": "ConsumerResourceOperation",
"bindingId": "Infrastructure.Machine.Action.Suspend",
"description": "Suspend a machine.",
"extensionId": null,
"formScale": null,
"hasForm": false,
"iconId": "machineSuspend.png",
"id": "2073db21-f708-44ab-b5b1-f80cf99e7b09",
"name": "Suspend",
"providerTypeId": "com.vmware.csp.iaas.blueprint.service",
"type": "ACTION"
}
],
"links": []
},