Conversation
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The new single_host flag logic (
single_host=len(entry_factory)>1) no longer matches the originalhosts is Nonesemantics—please verify it still produces the intended batching behavior when processing multiple entries. - There’s still duplicated logic for splitting FQDN into host and domain in the DNS record sections—extracting that into a helper would reduce code repetition and minimize edge‐case bugs.
- Even with the EntryFactory, the main function is extremely large; consider breaking out host command generation for each state/action into helper functions to improve readability and maintainability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new single_host flag logic (`single_host=len(entry_factory)>1`) no longer matches the original `hosts is None` semantics—please verify it still produces the intended batching behavior when processing multiple entries.
- There’s still duplicated logic for splitting FQDN into host and domain in the DNS record sections—extracting that into a helper would reduce code repetition and minimize edge‐case bugs.
- Even with the EntryFactory, the main function is extremely large; consider breaking out host command generation for each state/action into helper functions to improve readability and maintainability.
## Individual Comments
### Comment 1
<location> `plugins/modules/ipahost.py:658` </location>
<code_context>
result["result"]["randompassword"]
+def convert_sshpubkey(value):
+ """Ensure sshpubkey values are correct."""
+ if isinstance(value, list):
+ value = [str(normalize_sshpubkey(key)) for key in value]
+ if isinstance(value, (str, unicode)): # pylint: disable=E0606
+ value = str(normalize_sshpubkey(value))
+ return value
+
+
</code_context>
<issue_to_address>
convert_sshpubkey may not handle nested lists or None values robustly.
Please update convert_sshpubkey to handle None inputs and nested lists to prevent runtime errors.
</issue_to_address>
### Comment 2
<location> `plugins/module_utils/ansible_freeipa_module.py:540` </location>
<code_context>
return value
+def convert_param_value_to_uppercase(value):
+ if isinstance(value, list):
+ value = [v.upper() for v in value]
+ if isinstance(value, (str, unicode)):
+ value = value.upper()
+ return value
+
+
</code_context>
<issue_to_address>
convert_param_value_to_uppercase does not handle None values.
Explicitly handle None to ensure consistent behavior and prevent unintended results in downstream code.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1ccd618 to
35ea5d7
Compare
0b4a6a0 to
b246dff
Compare
|
Dowstream tests are passing with these changes. |
When comparing an argument dict to an IPA dict, the log messages were inconsistent and did not provide enough information for debugging. This change make the messages consistent and display the dict key being evaluated if the key result in tagging the dicts as different. Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
This patch moves the function used to ensure that hostnames used in ipasurule are FQDN and unique to module_utils, so it can be used by other modules than require the same behavior for a hostaname parameter. Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
When using ipahost with the 'hosts' parameters several parameter conversion routines were not being performed causing the module to try to execute tasks it was not suposed to. This issues were fixed by adapting the module to use EntryFactory. Another issue was happening when 'update_dns: true' is used with some parameters, like 'description', 'location' or 'mac_address', where, even if no change was to be performed the plugin would evaluate that the arguments were different, and tried to modify the object. The fix for this issue is to ignore 'updatedns' when comparing the parameters provided with the existing IPA object. This modification also fix the case where duplicate entries used with the 'name' parameter in case 'state: absent' would fail without indicating the use of duplicate entries. Fixes: freeipa#1296 Fixes: https://issues.redhat.com/browse/RHEL-111063 Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
b246dff to
e7819b1
Compare
varunmylaraiah
left a comment
There was a problem hiding this comment.
PR LGTM.
I’ve tested it against the existing upstream and downstream test suites, and all tests are passing.
|
|
||
| def module_params_get(module, name, allow_empty_list_item=False): | ||
| def module_params_get( | ||
| module, name, allow_empty_list_item=False, ignore_list_check=False |
There was a problem hiding this comment.
I ignore_list_check is enabled, enabling allow_empty_list_item does not have any impact.
There is no description for ignore_list_check and the use case etc. Also not in the ipahost change later on, where it is used.
| using_hosts = ansible_module.params_get("hosts") is not None | ||
|
|
||
| # Check parameters | ||
| invalid = [] |
There was a problem hiding this comment.
As invalid is now a variable that is used later on in the code, it should have a better name to make sure that it will not be used for something else.
|
Any news on this? |
|
If I can be of any help on this PR, please let me know. I would really love to see this merged |
|
@DorBreger this change will cause a huge impact on the way plugins are created, and we are postponing it for a few months. It is close to our radar, but we can't really do it right now as we have more pressure on other fronts. And there are some "not optimal" design decisions I made on this PR that I feel need to be addressed before it could be merged. A more realistic time frame (but still a crude estimate) is "second half of 2026". I'll certainly not touch it before May. |
I understand that this is a big change. We are facing an issue with |
|
We don't have any influence in the Note that ansible-freeipa plugins do not have underscore ( |
Fixes: #1296
Summary by Sourcery
Improve idempotence in the ipahost module by normalizing input values uniformly and refactoring host entry processing.
Bug Fixes:
Enhancements:
Tests: