I have a role ovirt_vm_add_disk_role
that creates a new disk for a VM with ovirt_disk
module.
In that role I register the variable disk_info
which contains the results of the ovirt_disk
module:
- name: "Update disk information"
ovirt_disk:
auth: "{{ ovirt_auth }}"
activate: true
name: "{{ disk_name }}"
poll_interval: 10
vm_name: "{{ HOSTNAME }}"
delegate_to: localhost
register: disk_info
The contents of disk_info
looks like:
"msg": [
{
"active": true,
"bootable": false,
"disk": {
"href": "/ovirt-engine/api/disks/6814659f-f89c-4b6e-b067-f09272b1095b",
"id": "6814659f-f89c-4b6e-b067-f09272b1095b"
},
"href": "/ovirt-engine/api/vms/3d76975e-b3e2-4fa5-8c27-5b3eca1825eb/diskattachments/6814659f-f89c-4b6e-b067-f09272b1095b",
"id": "6814659f-f89c-4b6e-b067-f09272b1095b",
"interface": "virtio_scsi",
"logical_name": "/dev/sde",
"pass_discard": false,
"read_only": false,
"uses_scsi_reservation": false,
"vm": {
"href": "/ovirt-engine/api/vms/3d76975e-b3e2-4fa5-8c27-5b3eca1825eb",
"id": "3d76975e-b3e2-4fa5-8c27-5b3eca1825eb"
}
}
]
When I call that role for a single disk everything is fine and I can use disk_info
in the playbook that called the role.
However when I need to loop over the role to add more than one disk I can only see disk_info
for the last iteration.
Loop:
- name: Add DATA Disks loop
vars:
disk_name: "{{ HOSTNAME }}_{{ item }}"
disk_size: "{{ disk_size }}"
disk_storage: "{{ invstorage_domain }}"
include_role:
name: ovirt_vm_add_disk_role
with_items: "{{ disks }}"
register: asm_data_devices
When adding to Disks with variable disks: ['DATA01','DATA02']
then disk_info
does only contain information about DATA02
.
Tried to register the outcome of the loop in variable asm_data_devices
but it does not contain return values of ovirt_disk
module at all:
"msg": [
{
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_loop_var": "item",
"include_args": {
"name": "ovirt_vm_add_disk_role",
"public": true
},
"item": "DATA01"
},
{
"ansible_loop_var": "item",
"include_args": {
"name": "ovirt_vm_add_disk_role",
"public": true
},
"item": "DATA02"
}
]
}
]
So how can I get the return values from ovirt_disk
module in outer playbook calling the role for all items of the loop?