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 < [ mailto:blanchet@abes.fr |
blanchet(a)abes.fr ] > wrote:
Hello gianluca,
[snip]
BQ_BEGIN
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' : [ [
http://label.name/ | label.name ] for label in labels],
## ajout NBT pour obtenir le nom de l'hote a la place de l ip
'ansible_host' : [
http://vm.name/ | vm.name ] ,
'affinity_groups' : [
BQ_END
Hello,
coming back to this PS of yours.
in my case [
http://vm.name/ | 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': [
http://vm.id/ | vm.id ] ,
'name': [
http://vm.name/ | vm.name ] ,
...
'devices': dict(
( [
http://device.name/ | 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': [
http://vm.id/ | vm.id ] ,
'name': [
http://vm.name/ | vm.name ] ,
...
'devices': dict(
( [
http://device.name/ | 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