Error restore snapshots ovirt ansible

I have the next playbooks:

  • ovirt_snapshots:
    auth: “{{ ovirt_auth }}”
    state: restore
    vm_name: dlitest02
    snapshot_id: “{{ snapshot.id }}”

but when i run the playbook the error is:

TASK [ovirt_snapshots] ****************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“failed”: true, “msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘snapshot’ is undefined\n\nThe error appears to have been in ‘/etc/ansible/ovirt/ovirt-restore-snapshot.yml’: line 14, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - ovirt_snapshots:\n ^ here\n”}

Does the virtual machine have to be turned off?

Thanks

The error message is saying what is wrong:

"... has an invalid value, which appears to include a variable that is undefined. The error was: 'snapshot' is undefined"

So you will need to define the variable snapshot somewhere in you code.

In the documentation the example he puts is:

http://docs.ansible.com/ansible/latest/ovirt_snapshots_module.html

# Restore snapshot:
- ovirt_snapshots:
    state: restore
    vm_name: rhel7
    snapshot_id: "{{ snapshot.id }}"

If you look at the two examples before that you see they create a snapshot and register the output in a variable snapshot.

Thats why they can use "{{ snapshot.id }}" as the id of what snapshot to manage. If you do not have a variable you will need to provide the id some other way.