diff --git a/changelogs/fragments/8489-fix-opennebula-inventory-crash-when-nic-has-no-ip.yml b/changelogs/fragments/8489-fix-opennebula-inventory-crash-when-nic-has-no-ip.yml new file mode 100644 index 0000000000..3db86f364e --- /dev/null +++ b/changelogs/fragments/8489-fix-opennebula-inventory-crash-when-nic-has-no-ip.yml @@ -0,0 +1,2 @@ +bugfixes: + - opennebula inventory plugin - fix invalid reference to IP when inventory runs against NICs with no IPv4 address (https://github.com/ansible-collections/community.general/pull/8489). diff --git a/plugins/inventory/opennebula.py b/plugins/inventory/opennebula.py index b097307c39..bf81758ef1 100644 --- a/plugins/inventory/opennebula.py +++ b/plugins/inventory/opennebula.py @@ -143,7 +143,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable): nic = [nic] for net in nic: - return net['IP'] + if net.get('IP'): + return net['IP'] return False