-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cobbler Inventory: allow users to specify extra groups #9420
base: main
Are you sure you want to change the base?
Conversation
Thanks for the contribution. I'm not sure though from first glance how I also think adding the Finally, as implemented the full system info is not cached (doubly important with the added overhead) and in facts breaks the second time it is run with a local cache:
I think you'll want to move the calls to I see how it could be useful for some people though, so it definitely is worth adding. |
How about adding a new option that determines the level of facts (maybe |
For Yeah, adding a new option like As for the massive increase in timing, just curious how many systems did you have in the inventory and what version of Cobbler? We're kinda tied down a specific version of Cobbler for now and was curious if updates are increasing/decreasing overhead on API calls Yeah, that's my bad - I didn't test the caching. The environment I'm in doesn't really work with caching of anything. We have so many systems, profiles, and distros that may change in between ansible-inventory runs... I'll test some stuff out at work on Monday/Tuesday with the caching, fixes, et cetera and bring those home to merge in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @Ty9000 thanks for your contribution.
The new feature seems to be fine, but I left some comments on some of the other changes made.
data = c.get_profiles() | ||
except (socket.gaierror, socket.error, xmlrpc_client.ProtocolError): | ||
data = self.c.get_profiles() | ||
except (gaierror, error, xmlrpc_client.ProtocolError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a personal preference, I think it is clearer what those errors are about when prefixed with socket.
. One year from now if I read this code, I would have to go back and forth to the imports to understand what's going on. In this case they are close and it would be very quick, but I think it would be a good practice to be more explicit about it. Just my $0.02
@@ -0,0 +1,2 @@ | |||
minor_changes: | |||
- inventory/cobbler.py - fix a few typos, simplify required library imports, request full rendered variables for Cobbler system, allow end user to specify extra groups to add systems to in Ansible inventory, should not change currently expected behavior (https://github.com/ansible-collections/community.general/issues/9419) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some required formatting changes, but also a bit of a style suggestion - we could/should be more concise in here.
- inventory/cobbler.py - fix a few typos, simplify required library imports, request full rendered variables for Cobbler system, allow end user to specify extra groups to add systems to in Ansible inventory, should not change currently expected behavior (https://github.com/ansible-collections/community.general/issues/9419) | |
- cobbler inventory plugin - fix typos, simplify required library imports, request full rendered variables for Cobbler system, allow end user to specify extra groups, should not change currently expected behavior (https://github.com/ansible-collections/community.general/issues/9419). |
Please refer to the standard formatting for the changelog fragments' entries:
https://docs.ansible.com/ansible/devel/community/development_process.html#changelogs-how-to-format
The outcome of this changelog fragment can be seen in the collection changelog:
https://docs.ansible.com/ansible/latest/collections/community/general/changelog.html
@@ -180,13 +185,13 @@ def _reload_cache(self): | |||
|
|||
def _get_profiles(self): | |||
if not self.use_cache or 'profiles' not in self._cache.get(self.cache_key, {}): | |||
c = self._get_connection() | |||
self.c = self._get_connection() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like calling the attribute c
. I am fine using these shortcuts in very localised contexts, specially for short-lived vars or comprehensions, but when it comes to actual attributes it is a good practice to have meaningful names.
Someone not familiar with the code, one year from now, should be able to read one of the methods below without having to go back and forth within the code to understand what c
means. connection? cache? cobbler? compute?
Ping @Ty9000 needs_info |
Sorry! I'm on a work trip and won't be back home for a couple more weeks... This is still on my radar and I'll get some updates pushed out mid-February, if that's okay |
No worries, it's mainly to make sure that PRs aren't completely abandoned :) (The bot will auto-close if nobody reacts in 2-3 months if the |
SUMMARY
Fix for #9419
Adds all rolled up Cobbler variables for a system to the Ansible inventory
Allows a user to specify multiple extra groups to add to the inventory
Fixed a few typos, simplify imports for required libraries
ISSUE TYPE
COMPONENT NAME
inventory/cobbler.py
ADDITIONAL INFORMATION
Tested on Cobbler 3.4.0