Trouble using dynamic inventory #21
-
Hi @spam-n-eggs and others! I have trouble getting the dynamic inventory to work. First time user of dynamic inventories, so maybe the problem lies with me. I'll show the steps I took below (Redactions in CAPITAL letters). In
Then I created an inventory file: ---
plugin: dominion_solutions.netbird.netbird
api_key: SERVICE_ACCOUNT_ACCESS_TOKEN
api_url: "https://NETBIRD/api/v1"
netbird_groups:
- "GROUP" Then I tried to get some output: ansible-inventory -i hosts.netbird.yaml --graph -vvv Output: ansible-inventory [core 2.16.4]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/USERNAME/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible
ansible collection location = /home/USERNAME/.ansible/collections:/usr/share/ansible/collections
executable location = /home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/bin/ansible-inventory
python version = 3.12.2 (main, Feb 7 2024, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] (/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/bin/python)
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml as it did not pass its verify_file() method
script declined parsing /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml as it did not pass its verify_file() method
Using inventory plugin 'ansible_collections.dominion_solutions.netbird.plugins.inventory.netbird' to process inventory source '/srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml'
Building the Netbird API Client.
Set up the Netbird API Client with the URL: https://NETBIRD/api/v1
toml declined parsing /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml as it did not pass its verify_file() method
[WARNING]: * Failed to parse /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml with auto plugin: Extra data: line 1 column 5 (char 4)
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/plugins/inventory/auto.py", line 59, in parse
plugin.parse(inventory, loader, path, cache=cache)
File "/home/USERNAME/.ansible/collections/ansible_collections/dominion_solutions/netbird/plugins/inventory/netbird.py", line 232, in parse
self._get_peer_inventory()
File "/home/USERNAME/.ansible/collections/ansible_collections/dominion_solutions/netbird/plugins/inventory/netbird.py", line 151, in _get_peer_inventory
self.peers = self.client.ListPeers()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/USERNAME/.ansible/collections/ansible_collections/dominion_solutions/netbird/plugins/inventory/netbird.py", line 289, in ListPeers
peer_json = json.loads(response.text)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
[WARNING]: * Failed to parse /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/plugins/inventory/yaml.py", line 114, in parse
raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]: * Failed to parse /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML
file.
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages/ansible/plugins/inventory/ini.py", line 138, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /srv/user/USERNAME/PROJECT/ansible/netbird_inventory/hosts.netbird.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
|--@ungrouped: I'm pretty sure I installed the requirements: > pip show requests
Name: requests
Version: 2.31.0
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: [email protected]
License: Apache 2.0
Location: /home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages
Requires: certifi, charset-normalizer, idna, urllib3
Required-by:
> pip show ansible
Name: ansible
Version: 9.3.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPL-3.0-or-later
Location: /home/USERNAME/.local/share/virtualenvs/nob-5mg6kQBn/lib/python3.12/site-packages
Requires: ansible-core
Required-by:
Any ideas what's going wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @euh2, I don't think Netbird has a "versioned" endpoint. Ideally this should be retuning an AnsibleError telling us that it's not a valid URL. Change the URL to Let us know if that fixes the issue. If it doesn't, we'll look further into it. See the documentation |
Beta Was this translation helpful? Give feedback.
-
@euh2 In version 0.1.6, I did add a more descriptive error message to tell you what's going on. |
Beta Was this translation helpful? Give feedback.
Hi @euh2,
I don't think Netbird has a "versioned" endpoint. Ideally this should be retuning an AnsibleError telling us that it's not a valid URL. Change the URL to
https://NETBIRD/api/
without a version on the end.Let us know if that fixes the issue. If it doesn't, we'll look further into it. See the documentation