On Wed, Dec 18, 2019 at 7:28 PM Nathanaël Blanchet <blanchet(a)abes.fr> wrote:
Hello Ondra what do you think about this question?
ovirt4.py may need some modifications to get required IPs/hostnames when
multiple vm has multiple interfaces ?
Personalized hack works for me but I have to modify the file each time I
upgrade AWX.
------------------------------
*De: *"Gianluca Cecchi" <gianluca.cecchi(a)gmail.com>
*À: *"Nathanaël Blanchet" <blanchet(a)abes.fr>
*Cc: *"users" <users(a)ovirt.org>
*Envoyé: *Mercredi 18 Décembre 2019 17:21:40
*Objet: *Re: [ovirt-users] AWX and error using ovirt as an inventory
source
On Thu, Nov 28, 2019 at 4:59 PM Nathanaël Blanchet <blanchet(a)abes.fr>
wrote:
> Hello gianluca,
>
[snip]
> PS: Something else that may help, try to hack the ovirt4.py with
> ansible_host if you want to call the hosts into playbook by the hostname
> and not the first IP:
>
> vi
>
/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/awx/plugins/inventory/ovirt4.py
> 'affinity_labels': [label.name for label in labels],
> ## ajout NBT pour obtenir le nom de l'hote a la place de l ip
> 'ansible_host': vm.name,
> 'affinity_groups': [
>
>
>
Hello,
coming back to this PS of yours.
in my case vm.name is not always resolvable, so it is not so feasible.
But also the default configuration of ansible_host seems quite
unfortunate....
With the default configuration, I see that for VMs with 2 ips, it gets the
eth1 one, not matching the VM hostname and so the job fails because of
unreachable host.
So I'm trying
substituting
/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/plugins/inventory/ovirt4.py
from
return {
'id': vm.id,
'name': vm.name,
...
'devices': dict(
(device.name, [ip.address for ip in device.ips]) for device
in devices if device.ips
),
'ansible_host': next((device.ips[0].address for device in devices
if device.ips), None)
}
to:
return {
'id': vm.id,
'name': vm.name,
...
'devices': dict(
(device.name, [ip.address for ip in device.ips]) for device
in devices if device.ips
),
'ansible_host': vm.fqdn
}
If I do this with my test tmp file I see that comparing output of command
(py36) bash-4.4# ./ovirt4.py
I have a new value for ansible_host, matching the fqdn of the VM
But going into awx, the job continues to fail and also if I go to
inventory -> sources and sync, even if I check all the "update options":
OVERWRITE
OVERWRITE VARIABLES
UPDATE ON LAUNCH
Still the vm contains ansible_host with the old value, matching the second
interface and not the fqdn...
Any suggestion?
Gianluca
Any feedback on this and why the sync of the inventory from the GUI doesn't
update the ansible_host variable?
Nathanaël, can you try, if you have a dev environment, to change the
ansible_host to another value and see if it is picked up or not?
In the mean time I see that in my bug entry for awx the status has been put
to need_info, but I don't know why and I have asked more info about it....
Gianluca