Closed bsanders closed 2 years ago
Files identified in the description:
contrib/inventory
lib/ansible/plugins/inventory
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
!component =plugins/inventory/opennebula.py
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.
cc @feldsam click here for bot help
Hi @bsanders , I don;t know how keyed groups work on backgroud, would you share xcepted result as json code? From what variables you want to get distribution? I don't see it in opennebula user template
I was not super clear on how the ansible_distribution was supposed to turn into keyed_groups either. I was looking at this [0], specifically the "examples". I guess I was assuming ansible would reach out to get the facts, including distro, then sort things into groups. But that wasn't happening.
To figure out what actually happens, I hacked the plugin and I've stepped through the code with pdb. With my changes, I'm able to say keyed_groups: key:some_opennebula_attribute
and it works. Not sure if key: ansible_distribution
is supposed to work or not.
Would you be willing to look at a PR to add this functionality? I may attempt to implement the other Constructable
features, though I'm not sure I'll need them myself.
[0] https://docs.ansible.com/ansible/latest/collections/ansible/builtin/constructed_inventory.html
This isn't a bug report, but a feature request. Inventory plugins have to opt-in to support keyed groups (and similar features).
The current documentation for the plugin says it supports it, but it's not implemented. I spent an hour trying to figure out what I was doing wrong before looking at the code and realizing it just wasn't implemented.
This is bug in documentation. So we can fix it, but how, when it is extended?
Ah, I completely missed the extends_documentation_fragment
. Sorry.
@feldsam basically what you need to do is: https://github.com/ansible-collections/community.general/blob/main/plugins/inventory/nmap.py#L86-L93
I have the code working. Currently looking into adding some unit tests.
I opened a PR; code is working, some test logic is failing (traceback in PR). If anyone watching knows why the 'InventoryModule' object has no attribute 'templar'
in the test, I'm all ears.
Summary
The documentation for the OpenNebula dynamic inventory plugin [0] refers to an option to created keyed_groups (because the documentation extends it).
However, this functionality is not implemented. Even though the
InventoryModule
inherits fromConstructable
,self._add_host_to_keyed_groups()
is never called.[0] https://docs.ansible.com/ansible/latest/collections/community/general/opennebula_inventory.html
Issue Type
Bug Report
Component Name
opennebula dynamic inventory plugin
Ansible Version
Community.general Version
Configuration
OS / Environment
Steps to Reproduce
opennebula.yml:
ansible-inventory --list -i opennebula.yml
Expected Results
I expected a grouping of hosts by distribution. Note that the plugin does perform grouping by LABEL, which is seen below with the
srv
andfoo
labels/groups.Actual Results