Skip to content
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

Workaround prompt issues between ROS 6.49 and 7.1.5 (#62) #161

Merged
merged 9 commits into from
Mar 23, 2023

Conversation

sgrimee
Copy link
Contributor

@sgrimee sgrimee commented Mar 22, 2023

SUMMARY

This addresses a bug introduced in ROS version 6.69 and resolved in 7.2 that would cause the stdout of commands to contain extraneous characters (often '/' or ':') by adding a whitespace in front of the command.

Fixes #62

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/module_utils/routeros.py

ADDITIONAL INFORMATION

This is achieved by leveraging the version number that is already collected in plugins/cliconf get_capabilities

If for some reason the version was not collected, this change will do nothing to preserve compatibility, but I could not find a case where it is not collected.

Version comparison is made using from ansible.module_utils.compat.version import LooseVersion so no new external dependency is added.

This fix can be tested with:

---
- hosts: test
  gather_facts: False
  tasks:
    - name: "Check stdout not polluted"
      community.routeros.command:
        commands:
          - :put ""
      register: result
      failed_when: result.stdout[0] != ""
      changed_when: False

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Could you please add a changelog fragment? Thanks.

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #161 (1e82eea) into main (4329928) will decrease coverage by 1.88%.
The diff coverage is 27.64%.

@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
- Coverage   86.45%   84.57%   -1.88%     
==========================================
  Files          30       32       +2     
  Lines        3727     3850     +123     
  Branches      679      710      +31     
==========================================
+ Hits         3222     3256      +34     
- Misses        367      456      +89     
  Partials      138      138              
Flag Coverage Δ
integration 66.86% <ø> (ø)
sanity 22.23% <27.64%> (+0.34%) ⬆️
units 84.54% <27.64%> (-1.93%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
plugins/module_utils/routeros.py 21.27% <22.22%> (+0.10%) ⬆️
plugins/module_utils/_version.py 25.45% <25.45%> (ø)
plugins/module_utils/version.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanity check error is because of this:

@felixfontein felixfontein merged commit c1a6ae8 into ansible-collections:main Mar 23, 2023
@felixfontein
Copy link
Collaborator

@sgrimee thanks a lot for implementing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra lines in stdout (ROS 6.49 to 7.1.5)
2 participants