Jan,
I just ran a quick test with your suggestion and it seems like it is
working as intended. I need to do more testing with it but it looks like
this may well be a viable solution:
---
- hosts: localhost
connection: local
vars:
host: hostX
cluster: default
directory: '/backup/'
ova_ext: ova
vms:
- ovatest
- ovatest2
tasks:
- name: Backup VMs
include_tasks: backup-test.yml
loop: "{{ vms }}"
backup-test.yml:
---
- name: "Export VM to OVA"
ovirt_vm:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: exported
cluster: "{{ cluster }}"
export_ova:
host: "{{ host }}"
filename: "{{ item }}.{{ ova_ext }}"
directory: "{{ directory }}"
- name: "Wait for export to finish"
wait_for:
path: "/backup/vm.ova" # will change to using vars here
The backup folder isn't accessible from where I'm running ansible from so I
will need to check it remotely but that should be easy to solve.
On Thu, Jan 23, 2020 at 11:43 AM Jan Zmeskal <jzmeskal(a)redhat.com> wrote:
Hi Jayme,
let us know how it went. Anyway, if you ever run into hard timeout, don't
despair. It also happened to me once when working with Ansible oVirt
modules and I just created an issue on GitHub where I requested this
timeout to be changed from hard-coded value to a configurable parameter
with some reasonable default. It was implemented rather quickly.
Jan
On Thu, Jan 23, 2020 at 4:32 PM Jayme <jaymef(a)gmail.com> wrote:
> That may work since the file will be tmp until finished being written. I
> was also just looking at the ovirt event info module
>
https://docs.ansible.com/ansible/latest/modules/ovirt_event_info_module.h...
--
> I was thinking that I might be able to watch the event info wait on the
> event which shows the export was successful i.e. Vm X was exported
> successfully as a Virtual Appliance to path....
>
> There is also the event index which could be useful in terms of getting a
> starting point for the event search.
>
> I thought there would be a module or API for the running oVirt task list
> but so far I haven't been able to find any way to get info on oVirt tasks.
>
> I'll see if I can get something working with your suggestion and keep
> looking at API and ansible modules to see which make sense to use.
>
> I'm also worried that timeout issues may occur if I start waiting in some
> cases an hour or more for very large VM backups to complete before moving
> on to the next with ansible.
>
> Thanks!
>
> Jayme
>
> On Thu, Jan 23, 2020 at 10:00 AM Jan Zmeskal <jzmeskal(a)redhat.com> wrote:
>
>> Hi Jayme,
>>
>> here's my idea. I haven't tested it but I believe it should work.
>> 1. Create a new task file (let's call it export_vm.yaml) and include two
>> tasks in there:
>> 1.1. First task uses ovirt_vm module (pretty much what you already have)
>> to export VM
>> 1.2. Second task uses wait_for
>> <
https://docs.ansible.com/ansible/latest/modules/wait_for_module.html>
>> module (specifically its path parameter) to wait until the OVA file in
>> /backup exists
>> 2. Loop over those two tasks as explained here
>> <
https://ericsysmin.com/2019/06/20/how-to-loop-blocks-of-code-in-ansible/>
>> .
>>
>> Hope this helps.
>>
>> Jan
>>
>> On Wed, Jan 22, 2020 at 4:15 PM Jayme <jaymef(a)gmail.com> wrote:
>>
>>> I wrote a simple task that is using the ovirt_vm module
>>>
https://docs.ansible.com/ansible/latest/modules/ovirt_vm_module.html --
>>> it essentially loops over a list of vms and exports them to OVA.
>>>
>>> The problem I have is the task is deemed changed once it successfully
>>> submits the export task to oVirt. This means that if I gave it a list of
>>> 100 Vms I believe it would start an export task on all of them. I want to
>>> prevent this and have it only export one VM at a time. In order to do this
>>> I believe I will need to find a way for the task to wait and somehow verify
>>> that the export was completed before submitting a task for the next VM
>>> export.
>>>
>>> Any ideas?
>>>
>>> - name: Export the VM
>>> ovirt_vm:
>>> auth: "{{ ovirt_auth }}"
>>> name: "{{ item }}"
>>> state: exported
>>> cluster: default
>>> export_ova:
>>> host: Host0
>>> filename: "{{ item }}"
>>> directory: /backup/
>>> with_items: "{{ vms }}"
>>>
>>> _______________________________________________
>>> Users mailing list -- users(a)ovirt.org
>>> To unsubscribe send an email to users-leave(a)ovirt.org
>>> Privacy Statement:
https://www.ovirt.org/site/privacy-policy/
>>> oVirt Code of Conduct:
>>>
https://www.ovirt.org/community/about/community-guidelines/
>>> List Archives:
>>>
https://lists.ovirt.org/archives/list/users@ovirt.org/message/PXYAQ7YEBQC...
>>>
>>
>>
>> --
>>
>> Jan Zmeskal
>>
>> Quality Engineer, RHV Core System
>>
>> Red Hat <
https://www.redhat.com>
>> <
https://www.redhat.com>
>>
>
--
Jan Zmeskal
Quality Engineer, RHV Core System
Red Hat <
https://www.redhat.com>
<
https://www.redhat.com>