ovirt-ansible-collection
ovirt-ansible-collection copied to clipboard
Cannot download snapshot disk image
SUMMARY
I want to create a snapshot and download a copy of the virtual disk to my local machine.
COMPONENT NAME
ovirt.ovirt.ovirt_snapshot
STEPS TO REPRODUCE
- name: Take the snapshot.
ovirt.ovirt.ovirt_snapshot:
auth: "{{ ovirt_auth }}"
vm_name: my_vm_name
description: test_ansible_snapshot
use_memory: false
register: snapshot_status
- name: Download the snapshot
when: snapshot_status is succeeded
ovirt.ovirt.ovirt_snapshot:
auth: "{{ ovirt_auth }}"
snapshot_id: "{{ snapshot_status.id }}"
disk_name: my_vm_name_OS
vm_name: my_vm_name
download_image_path: /home/my_user/my_vm_name_OS.qcow2
EXPECTED RESULTS
Download the virtual disk.
ACTUAL RESULTS
TASK [Download the snapshot] **********************************************************************************************
task path: /home/my_user/repos/playbooks/snapshot_vm.yml:25
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: my_user
<127.0.0.1> EXEC /bin/sh -c 'echo ~my_user && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/my_user/.ansible/tmp `"&& mkdir "` echo /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399 `" && echo ansible-tmp-1706027196.0007439-25710-161988586248399="` echo /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399 `" ) && sleep 0'
Using module file /home/my_user/.ansible/collections/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_snapshot.py
<127.0.0.1> PUT /home/my_user/.ansible/tmp/ansible-local-25544_dk6132v/tmpduq4klhn TO /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399/AnsiballZ_ovirt_snapshot.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399/ /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399/AnsiballZ_ovirt_snapshot.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399/AnsiballZ_ovirt_snapshot.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/my_user/.ansible/tmp/ansible-tmp-1706027196.0007439-25710-161988586248399/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ovirt.ovirt.ovirt_snapshot_payload_mqhz77tj/ansible_ovirt.ovirt.ovirt_snapshot_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_snapshot.py", line 554, in main
File "/tmp/ansible_ovirt.ovirt.ovirt_snapshot_payload_mqhz77tj/ansible_ovirt.ovirt.ovirt_snapshot_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_snapshot.py", line 348, in download_disk_image
File "/tmp/ansible_ovirt.ovirt.ovirt_snapshot_payload_mqhz77tj/ansible_ovirt.ovirt.ovirt_snapshot_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_snapshot.py", line 266, in transfer
AttributeError: 'ImageTransfer' object has no attribute 'signed_ticket'
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"auth": {
"ca_file": null,
"compress": true,
"headers": null,
"hostname": null,
"insecure": true,
"kerberos": false,
"password": null,
"timeout": 0,
"token": "7TsVjHVT68r2MG0Q4XLF9z-P0zdo85A6oC2-0dz05naedwa5e3-_Sv-6D8OSulB7PuFmXe7nRfgTk61ePuIpEg",
"url": "https://myServer.my.domain.com/ovirt-engine/api",
"username": null
},
"description": null,
"disk_id": "15d7b384-4f97-4d87-bed0-0ec97a28e108",
"disk_name": "my_vm_name_OS",
"disks": null,
"download_image_path": "/home/my_user/my_vm_name_OS.qcow2",
"fetch_nested": false,
"keep_days_old": null,
"nested_attributes": [],
"poll_interval": 3,
"snapshot_id": "b9c49aaa-137a-435f-a153-eb5645d10671",
"state": "present",
"timeout": 180,
"upload_image_path": null,
"use_memory": null,
"vm_id": null,
"vm_name": "my_vm_name",
"wait": true
}
},
"msg": "'ImageTransfer' object has no attribute 'signed_ticket'"
}
Using ovirt-engine-sdk-python v4.4.15.
Ansible info:
ansible-playbook [core 2.14.9]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/my_user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/my_user/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.9.18 (main, Sep 7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2.1.0.1)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
The snapshot is created successfully, just can't download the virtual disk. I was working from the examples here.
I did try to switch it up and instead of using:
disk_name: my_vm_name_OS
I tried
disks:
- id: aa352242-3645-40ab-85f3-14777a1d32e7
Which errors out complaining the id attribute doesn't exist.
Also
disks:
- name: my_vm_name_OS
Which doesn't error, but provides the following output (but no downloaded file):
ok: [localhost] => {
"changed": false,
"id": "14e01465-5404-4eb9-baa0-67c664fcb2e3",
"invocation": {
"module_args": {
"auth": {
"ca_file": null,
"compress": true,
"headers": null,
"hostname": null,
"insecure": true,
"kerberos": false,
"password": null,
"timeout": 0,
"token": "ix_5KxD5P9jQUHfdJPjyX25SbvNguOTkCdsJQ2DHCpzg2QwPSBkxddpud7Lq33IfZOCcXOg93KrsNlk0AvvqWg",
"url": "https://my_server.my.domain.com/ovirt-engine/api",
"username": null
},
"description": null,
"disk_id": null,
"disk_name": null,
"disks": [
{
"id": null,
"name": "my_vm_name_OS"
}
],
"download_image_path": "/home/my_user/my_vm_name_OS.qcow2",
"fetch_nested": false,
"keep_days_old": null,
"nested_attributes": [],
"poll_interval": 3,
"snapshot_id": "14e01465-5404-4eb9-baa0-67c664fcb2e3",
"state": "present",
"timeout": 180,
"upload_image_path": null,
"use_memory": null,
"vm_id": null,
"vm_name": "my_vm_name",
"wait": true
}
},
"snapshot": {
"cdroms": [],
"date": "2024-01-23 16:35:33.942000+00:00",
"description": "test_ansible_snapshot",
"disks": [],
"href": "/ovirt-engine/api/vms/7f7ad322-77c0-4b01-9f55-3fcf24683302/snapshots/14e01465-5404-4eb9-baa0-67c664fcb2e3",
"id": "14e01465-5404-4eb9-baa0-67c664fcb2e3",
"nics": [],
"persist_memorystate": false,
"snapshot_status": "ok",
"snapshot_type": "regular",
"vm": {
"bios": {
"boot_menu": {
"enabled": false
},
"type": "i440fx_sea_bios"
},
"cluster": {
"id": "c28c3a6f-ae93-4ec5-bb6a-81c0da14d3d1"
},
"comment": "my_company",
"cpu": {
"architecture": "x86_64",
"topology": {
"cores": 1,
"sockets": 10,
"threads": 1
}
},
"cpu_profile": {
"id": "df9acc9b-898d-4997-89f7-4fa1588bf786"
},
"cpu_shares": 0,
"creation_time": "2023-12-29 10:05:21+00:00",
"delete_protected": false,
"description": "my_vm",
"display": {
"allow_override": true,
"copy_paste_enabled": true,
"disconnect_action": "LOCK_SCREEN",
"file_transfer_enabled": true,
"keyboard_layout": "en-gb",
"monitors": 1,
"smartcard_enabled": false
},
"high_availability": {
"enabled": false,
"priority": 1
},
"id": "7f7ad322-77c0-4b01-9f55-3fcf24683302",
"io": {
"threads": 1
},
"large_icon": {
"id": "472b162e-1d10-b766-8cdd-e759b314f08a"
},
"memory": 10737418240,
"memory_policy": {
"ballooning": true,
"guaranteed": 10737418240,
"max": 10737418240
},
"migration": {
"auto_converge": "inherit",
"compressed": "inherit",
"encrypted": "inherit"
},
"migration_downtime": -1,
"multi_queues_enabled": true,
"name": "my_vm_name",
"next_run_configuration_exists": false,
"origin": "ovirt",
"original_template": {
"id": "00000000-0000-0000-0000-000000000000"
},
"os": {
"boot": {
"devices": [
"hd"
]
},
"type": "windows_2019x64"
},
"placement_policy": {
"affinity": "user_migratable"
},
"small_icon": {
"id": "a033f60e-4d6e-166b-1449-d3d426e57ac6"
},
"sso": {
"methods": [
{
"id": "guest_agent"
}
]
},
"start_paused": false,
"stateless": false,
"status": "down",
"stop_time": "2023-12-29 10:05:24+00:00",
"storage_error_resume_behaviour": "auto_resume",
"template": {
"id": "00000000-0000-0000-0000-000000000000"
},
"time_zone": {
"name": "GMT Standard Time"
},
"type": "server",
"usb": {
"enabled": false
},
"virtio_scsi_multi_queues_enabled": false
}
}
}