Support expect raw responses#80173
Conversation
|
The test |
|
|
||
| # one between responses and raw_responses needs to be specified | ||
| if responses is None and raw_responses is None: | ||
| module.fail_json(msg="responses (or raw_responses) is required") |
There was a problem hiding this comment.
Instead of this block, use required_one_of for AnsibleModule:
module = AnsibleModule(
argument_spec=...,
required_one_of=[['responses', 'raw_responses']],
)There was a problem hiding this comment.
Thank you @sivel for the feedback, I have updated the PR to implement your suggestion!
|
@sivel I have just updated the version added attribute based on the next release, please let me know if and how I can improve the PR. Thank you in advance! |
|
I would need this functionality. What can we do to help move it along? |
|
Hi @juresaht2! Honestly I am a little bit unsure on how to proceed here. For sure I can try to rebase it in the next few days so that it will be aligned again with the target branch and back to "able to merge" status, although it will need to be reviewed first. |
|
I've tried making an issue to Red Hat to get their attention, but apparently we'd need a subscription to one of their Ansible products for them to even look at this outside of techsupportistan, so we're stuck waiting for someone with maintainer privileges to merge the code or at least provide feedback. I suppose technically one could modify the local |
Yes I agree. In any case, to keep things aligned, I will rebase the branch with the target one by this weekend. |
|
The test |
|
@juresaht2 I have rebased the PR so that now it is still aligned with the target branch and resolving the conflicts that were present. |
SUMMARY
Fixes #80075.
The idea, as mentioned in the comment in the related issue, is to add the possibility to specify also
raw_responses, namely responses where the newline won't be added to the response and so suitable to all the cases in which the prompt expects a single character and immediately continues its execution after reading it, avoiding so the newline character to be read as answer of the next prompt.In the module, I thought about extracting the processing of the responses to a function, which accepts as parameter if it needs to add the newline to the processed responses or not, since most of the processing is equal in both cases and only the (possibly) appended character changes.
I added the new parameter in the related documentation with a couple of examples, and, since this is my first feature contribution, I hope I did not miss any step on this.
Regarding the test, it was personally more challenging since I tried to work on a cross-platform solution which was not depending on external libraries, but I will be more than happy to improve it based on your feedback.
ISSUE TYPE
COMPONENT NAME
expectmoduleADDITIONAL INFORMATION
Compared output: