Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linode dynamic inventory plugin fails with ip_style=api due to missing ipv6 pools #8213

Open
1 task done
ashtarcommunications opened this issue Apr 11, 2024 · 8 comments · May be fixed by #8248
Open
1 task done

Linode dynamic inventory plugin fails with ip_style=api due to missing ipv6 pools #8213

ashtarcommunications opened this issue Apr 11, 2024 · 8 comments · May be fixed by #8248
Labels
bug This issue/PR relates to a bug cloud has_pr inventory inventory plugin plugins plugin (any type) traceback

Comments

@ashtarcommunications
Copy link

Summary

The linode dynamic inventory plugin fails to parse the inventory when ip_style is set to "api", with an error about a missing attribute instance.ips.ipv6.pools

This appears to be due to line 221:

ips += instance.ips.ipv6.pools

I don't see

Issue Type

Bug Report

Component Name

linode

Ansible Version

$ ansible --version
ansible [core 2.15.2]
  python version = 3.11.4 (main, Jun  9 2023, 07:59:55) [GCC 12.3.0] (/usr/bin/python3)
  jinja version = 3.1.2

Community.general Version

$ ansible-galaxy collection list community.general
community.general 7.2.0

Configuration

$ ansible-config dump --only-changed

OS / Environment

Ubuntu 23.04

Steps to Reproduce

plugin: community.general.linode
access_token: "<token>"
ip_style: api

Expected Results

Would expect the inventory plugin to correctly parse the response from the linode API

Actual Results

[WARNING]:  * Failed to parse linode.yml with ansible_collections.community.general.plugins.inventory.linode plugin:
'MappedObject' object has no attribute 'pools'
  File "/home/ansible/.local/lib/python3.11/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/home/ansible/.local/lib/python3.11/site-packages/ansible_collections/community/general/plugins/inventory/linode.py", line 313, in parse
    self.populate()
  File "/home/ansible/.local/lib/python3.11/site-packages/ansible_collections/community/general/plugins/inventory/linode.py", line 255, in populate
    self._add_hostvars_for_instances()
  File "/home/ansible/.local/lib/python3.11/site-packages/ansible_collections/community/general/plugins/inventory/linode.py", line 220, in _add_hostvars_for_instances
    ips += instance.ips.ipv6.pools

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug cloud inventory inventory plugin plugins plugin (any type) traceback labels Apr 11, 2024
@felixfontein
Copy link
Collaborator

It looks like pools was renamed to ranges in linode/linode_api4-python@dc592c7. This was introduced in version 5.4.1: https://github.com/linode/linode_api4-python/releases/tag/v5.4.1

(I really wonder what kind of versioning scheme they use? Breaking changes in a patch version doesn't sound like a good idea to me... Also the PR doesn't mention any kind of motivation for the rename, which doesn't make it any better...)

@felixfontein
Copy link
Collaborator

I created a PR to fix this, could you please test it? #8248

(I have no way to test this.)

@ashtarcommunications
Copy link
Author

I get:
'IPv6Range' object has no attribute 'type'
and the inventory fails to parse

@felixfontein
Copy link
Collaborator

Can you paste the full stack trace? Thanks.

@ashtarcommunications
Copy link
Author

ashtarcommunications commented Apr 24, 2024

Failed to parse linode.yml with ansible_collections.community.general.plugins.inventory.linode plugin:
'IPv6Range' object has no attribute 'type'
  File "/home/<user>/.local/lib/python3.11/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/home/<user>/.ansible/collections/ansible_collections/community/general/plugins/inventory/linode.py", line 334, in parse
    self.populate()
  File "/home/<user>/.ansible/collections/ansible_collections/community/general/plugins/inventory/linode.py", line 262, in populate
    self._add_hostvars_for_instances()
  File "/home/<user>/.ansible/collections/ansible_collections/community/general/plugins/inventory/linode.py", line 229, in _add_hostvars_for_instances
    for ip_type in set(ip.type for ip in ips):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/.ansible/collections/ansible_collections/community/general/plugins/inventory/linode.py", line 229, in <genexpr>
    for ip_type in set(ip.type for ip in ips):
                       ^^^^^^^
  File "/home/<user>/.local/lib/python3.11/site-packages/linode_api4/objects/base.py", line 227, in __getattribute__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@felixfontein
Copy link
Collaborator

I guess in that case further things have changed in a backwards incompatible way. It's probably best if someone who can actually run the plugin against the real service continues debugging and fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug cloud has_pr inventory inventory plugin plugins plugin (any type) traceback
Projects
None yet
3 participants