ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
816 stars 1.5k forks source link

[PR #8489/3716187f backport][stable-8] Fix OpenNebula inventory crash when NIC does not have IP #8518

Closed patchback[bot] closed 3 months ago

patchback[bot] commented 3 months ago

This is a backport of PR #8489 as merged into main (3716187fc35cb9ea8a0722745124bf2d9399246a).

SUMMARY

Fix OpenNebula inventory crash when NIC does not have IP.

Now matches IPv6 behaviour.

ISSUE TYPE

community.general.opennebula

ADDITIONAL INFORMATION

When a NIC does not have an IP:

  File "ansible/inventory/manager.py", line 292, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "ansible-cm/plugins/inventory/opennebula.py", line 263, in parse
    self._populate()
  File "ansible-cm/plugins/inventory/opennebula.py", line 226, in _populate
    servers = self._retrieve_servers(filter_by_label)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ansible-cm/plugins/inventory/opennebula.py", line 210, in _retrieve_servers
    server['v4_first_ip'] = self._get_vm_ipv4(vm)
                            ^^^^^^^^^^^^^^^^^^^^^
  File "ansible-cm/plugins/inventory/opennebula.py", line 154, in _get_vm_ipv4
    return net['IP']