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

No inventory was parsed #579

Open
ziermmar opened this issue Nov 3, 2024 · 3 comments
Open

No inventory was parsed #579

ziermmar opened this issue Nov 3, 2024 · 3 comments

Comments

@ziermmar
Copy link

ziermmar commented Nov 3, 2024

SUMMARY

Similar to #495. Inventory is empty after ansible core upgrade 2.17.5 and hcloud update to 4.2.1

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud.hcloud

ANSIBLE VERSION
ansible [core 2.17.5]
  config file = None
  configured module search path = ['/Users/kef/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/kef/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.10 (main, Sep  7 2024, 01:03:31) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/opt/[email protected]/bin/python3.11)
  jinja version = 3.1.3
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list hetzner.hcloud

# /Users/kef/.ansible/collections/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 4.2.1  
CONFIGURATION
CONFIG_FILE() = /Users/kef/Development/ansible/ansible.cfg
DEFAULT_HOST_LIST(/Users/kef/Development/ansible/ansible.cfg) = ['/Users/kef/Development/ansible/shop.hcloud.yml']
DEFAULT_REMOTE_USER(/Users/kef/Development/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(/Users/kef/Development/ansible/ansible.cfg) = ['/Users/kef/Development/ansible/roles']
OS / ENVIRONMENT

Ubuntu 24.04

STEPS TO REPRODUCE
ansible-inventory --graph -vvv
EXPECTED RESULTS

Inventory host graph with several servers

ACTUAL RESULTS
ansible-inventory --graph -vvv

ansible-inventory [core 2.17.5]
  config file = /Users/kef/Development/ansible/ansible.cfg
  configured module search path = ['/Users/kef/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/kef/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible-inventory
  python version = 3.11.10 (main, Sep  7 2024, 01:03:31) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/opt/[email protected]/bin/python3.11)
  jinja version = 3.1.3
  libyaml = True
Using /Users/kef/Development/ansible/ansible.cfg as config file
host_list declined parsing /Users/kef/Development/ansible/shop.hcloud.yml as it did not pass its verify_file() method
script declined parsing /Users/kef/Development/ansible/shop.hcloud.yml as it did not pass its verify_file() method
Using inventory plugin 'ansible_collections.hetzner.hcloud.plugins.inventory.hcloud' to process inventory source '/Users/kef/Development/ansible/shop.hcloud.yml'
toml declined parsing /Users/kef/Development/ansible/shop.hcloud.yml as it did not pass its verify_file() method
[WARNING]:  * Failed to parse /Users/kef/Development/ansible/shop.hcloud.yml with auto plugin: 'NoneType' object is not callable
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/inventory/manager.py", line 292, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/inventory/hcloud.py", line 473, in parse
    servers = [self._build_inventory_server(s) for s in self._fetch_servers()]
                                                        ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/inventory/hcloud.py", line 317, in _fetch_servers
    servers = self.client.servers.get_all(**get_servers_params)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/client.py", line 567, in get_all
    return self._iter_pages(
           ^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/client.py", line 33, in _iter_pages
    result, meta = list_function(
                   ^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/client.py", line 546, in get_list
    ass_servers = [
                  ^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/client.py", line 547, in <listcomp>
    BoundServer(self, server_data) for server_data in response["servers"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/client.py", line 75, in __init__
    data["image"] = BoundImage(client._client.images, image)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py", line 34, in __init__
    super().__init__(client, data)
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/client.py", line 74, in __init__
    self.data_model = self.model.from_dict(data)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py", line 13, in from_dict
    return cls(**supported_data)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kef/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/domain.py", line 102, in __init__
    self.created = isoparse(created) if created else None
                   ^^^^^^^^^^^^^^^^^
[WARNING]:  * Failed to parse /Users/kef/Development/ansible/shop.hcloud.yml with yaml plugin: Plugin configuration YAML file, not YAML
inventory
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/inventory/manager.py", line 292, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/plugins/inventory/yaml.py", line 113, in parse
    raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse /Users/kef/Development/ansible/shop.hcloud.yml with ini plugin: Invalid host pattern '---' supplied, '---' is
normally a sign this is a YAML file.
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/inventory/manager.py", line 292, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/homebrew/lib/python3.11/site-packages/ansible/plugins/inventory/ini.py", line 137, in parse
    raise AnsibleParserError(e)
[WARNING]: Unable to parse /Users/kef/Development/ansible/shop.hcloud.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:
@jooola
Copy link
Collaborator

jooola commented Nov 4, 2024

@ziermmar Could you provide us the inventory configuration so we can reproduce your issue?

@ziermmar
Copy link
Author

ziermmar commented Nov 9, 2024

That's what was working before upgrading:

---
plugin: hetzner.hcloud.hcloud
api_token: !vault |
          $ANSIBLE_VAULT;1.2;AES256;apm
           <vault data redacted>
keyed_groups:
  - key: location
    prefix: hcloud_location
  - key: image_os_flavor
    separator: ""
  - key: status
    prefix: server_status

@jooola
Copy link
Collaborator

jooola commented Nov 22, 2024

I am having some difficulties reproducing this.

The exception seem to show that the isoparse could not be imported, which mean the python-dateutil library could not be found. But the code has a check for that. Could you tell me if the python-dateutil package is installed in the env where ansible is installed?

See the requirements: https://docs.ansible.com/ansible/latest/collections/hetzner/hcloud/hcloud_inventory.html#requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants