I believe I have identified the issue, variable inheritance.

The inventory I include to define the hosts, includes several classes.  
‘virtualmachines’ which the script uses to get the list of VMs it is going to 
process.  All VM defaults are defined within its ‘:vars’ section.

I also have groups of VMs where I want to override variables.   Unfortunately, 
what is being defined in ‘virtualmachines’ is not being override in the class 
level, because they are considered sibling classes.

I have found the ‘ansible_group_priority’ variable, which can be assigned at 
each class.  I assigned the entry in [virtualmachines:vars] with the value of 2 
(default is 1) and then in the other classes, I assigned a value of 3.

Now the variable in [class:vars] will override the variables in 
[virtualmachines:vars].   Of course the host level can still override all.

From: matthew.st...@fujitsu.com <matthew.st...@fujitsu.com>
Sent: Thursday, April 22, 2021 2:01 PM
To: Martin Perina <mper...@redhat.com>
Cc: users@ovirt.org; Martin Necas <mne...@redhat.com>
Subject: [ovirt-users] Re: Ansible ovirt.ovirt_vm nics

It’s basically the one listed in the URL.   The changes I’ve made is to add 
some addition ‘defaults’, and the code I mentioned below, to select different 
nic profiles for vms that are on different networks.

I’m running an Oracle Linux 7u9 system, and the version of Ansible is 2.9.18

In my environment, I have created different networks, and labeled them based 
upon their vlan tag number (vlan20, vlan21, vlan22, …)

A VM can be created on any of these vlans, so I need to be able to select the 
nic profile within ‘ini’ file holding all the configuration information. 
(hostname, fqdn, IP address, etc…)


From: Martin Perina <mper...@redhat.com<mailto:mper...@redhat.com>>
Sent: Thursday, April 22, 2021 2:51 AM
To: Stier, Matthew <matthew.st...@fujitsu.com<mailto:matthew.st...@fujitsu.com>>
Cc: users@ovirt.org<mailto:users@ovirt.org>; Martin Necas 
<mne...@redhat.com<mailto:mne...@redhat.com>>
Subject: Re: [ovirt-users] Ansible ovirt.ovirt_vm nics

Hi Matthew,

Could you please share with us your playbook? Which ansible version are you 
using? Are you using ovirt_vm module from oVirt Ansible Collection which 
contains newer versions than the ovirt_vm module included in Ansible 2.9?

https://docs.ansible.com/ansible/latest/collections/ovirt/ovirt/ovirt_vm_module.html

Thanks,
Martin


On Thu, Apr 22, 2021 at 9:28 AM 
matthew.st...@fujitsu.com<mailto:matthew.st...@fujitsu.com> 
<matthew.st...@fujitsu.com<mailto:matthew.st...@fujitsu.com>> wrote:
The ‘nics’ section of ovirt_vm is vague and with nearly no examples.

My playbook is based upon 
https://blogs.oracle.com/scoter/ansible-with-oracle-linux-virtualization-manager-olvm

I’ve made several modifications, (more default) and added a few lines, which I 
believe is supposed to assign vnic profiles to the primary vnic (nic1), based 
upon the definition of ‘vm_nic1_profile’ defined in an included ‘ini’ file. 
(the profile defaulting to blank if it is not defined in the ini file.)

It isn’t doing its job.

  nics:

-   name: “nic1”

profile_name: "{{ hostvars[item]['vm_nic1_profile'] | default('') }}”


The playbook runs without complaint.  If I run it with option ‘-vvv’ part of 
the output lists the variables, but the ‘nics’ variable is an empty list 
(nics[])

Any hints on what I’m doing wrong?   I’ve checked the forum, but it tends to 
strip leading spaces, which is bad for indent sensitive code.
_______________________________________________
Users mailing list -- users@ovirt.org<mailto:users@ovirt.org>
To unsubscribe send an email to 
users-le...@ovirt.org<mailto:users-le...@ovirt.org>
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/users@ovirt.org/message/MEZLXGSSRCRJRSMME7J3Y5XQ2AGYUWI4/


--
Martin Perina
Manager, Software Engineering
Red Hat Czech s.r.o.
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-le...@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/users@ovirt.org/message/QTE4FA7CY4UOOZIZMJAROZBL7T6DEWUA/

Reply via email to