This commit is contained in:
Felix Fontein 2025-03-29 22:34:14 +01:00 committed by GitHub
commit 80ea4355be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,4 @@
bugfixes:
- "linode inventory plugin - linode_api4 renamed the IPv6 ``pools`` to ``ranges`` in version 5.4.1. The plugin now checks the package
version to use the appropriate name (https://github.com/ansible-collections/community.general/issues/8213,
https://github.com/ansible-collections/community.general/pull/8248)."

View file

@ -130,10 +130,12 @@ from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try:
from linode_api4 import LinodeClient
from linode_api4.linode_client import package_version
from linode_api4.objects.linode import Instance
from linode_api4.errors import ApiError as LinodeApiError
HAS_LINODE = True
@ -225,7 +227,12 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
if ip_style == 'api':
ips = instance.ips.ipv4.public + instance.ips.ipv4.private
ips += [instance.ips.ipv6.slaac, instance.ips.ipv6.link_local]
ips += instance.ips.ipv6.pools
# linode_api4 renamed pools to ranges in 5.4.1 (https://github.com/linode/linode_api4-python/releases/tag/v5.4.1,
# https://github.com/linode/linode_api4-python/commit/dc592c706518abc1c6d4b4c88b074970e5375d5f)
if LooseVersion(package_version) < LooseVersion("5.4.1"):
ips += instance.ips.ipv6.pools
else:
ips += instance.ips.ipv6.ranges
for ip_type in set(ip.type for ip in ips):
self.inventory.set_variable(