Bug 1601445

Summary: Role fails when vms list is empty
Product: [oVirt] ovirt-ansible-collection Reporter: Petr Kubica <pkubica>
Component: vm-infraAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Kubica <pkubica>
Severity: low Docs Contact:
Priority: unspecified    
Version: 1.1.6CC: mperina, pkubica
Target Milestone: ovirt-4.2.6Flags: rule-engine: ovirt-4.2+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-ansible-vm-infra-1.1.9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-03 15:08:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Kubica 2018-07-16 12:22:18 UTC
Description of problem:
Role fails when vms: []
It should finish successfully.

Version-Release number of selected component (if applicable):
ovirt-ansible-vm-infra-1.1.8-1.el7ev.noarch

How reproducible:
always

Steps to Reproduce:
1. run role vm-infra with 'vms: []'

Actual results:
failed

Expected results:
should success

Additional info:
TASK [ovirt-vm-infra : Create VMs] *************************************
task path: /usr/share/ansible/roles/oVirt.vm-infra/tasks/main.yml:21

TASK [ovirt-vm-infra : Wait for VMs to be added] ************************************************************************
task path: /usr/share/ansible/roles/oVirt.vm-infra/tasks/main.yml:27
fatal: [localhost]: FAILED! => {
    "msg": "'all_vms' is undefined"
}

Comment 1 Martin Perina 2018-07-31 05:35:19 UTC
Is there any reason why the role should finish successfully when there are no VMs to be created/started? Shouldn't we rather make error message more clear, that users needs to specify at least 1 VM in vms option? Or am I missing something?

Comment 2 Petr Kubica 2018-07-31 12:24:24 UTC
I'm creating vms list dynamically using this role and in some rare cases it could happen that my dynamic list is empty. I can workaround it by testing: 'when: vms is not []' when I'm including this role, but at first I expected that if there isn't any change (any VM to create) it should pass as with "ok" or "skipped" to next tasks, because 'do nothing' isn't an error state in this case. But I understand your point of view about specifying at least 1 VM in vms and clear error message to explicitly say to users that they don't create any VMs.

Comment 3 Petr Kubica 2018-08-20 12:04:03 UTC
Verified ovirt-ansible-vm-infra-1.1.10-0.1.master.20180815145127.el7.noarch