-
Notifications
You must be signed in to change notification settings - Fork 47
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
RouterOS - issue with routeros_facts when interface has a space in name #8
Comments
CC @heuels |
Hey @danpospisil, thank for reporting this. Would you have the time to create a pull request with the fix you're proposing? @felixfontein, thanks for mentioning me ;) |
@heuels - sure, but first I want to ask which repo is correct? I see there was some massive refactoring done in this separate repo (i suppose it will be used starting Ansible 2.10.x, but Ansible 2.9.9 is using the original repo - https://github.com/ansible/ansible/blob/v2.9.9/lib/ansible/modules/network/routeros/routeros_facts.py and not this one. |
All changes have to get merged in this repo first before they can be backported to the stable-2.9 branch in the ansible/ansible repo. |
@felixfontein - unfortunately routeros_facts.py file in this repo after refactoring doesn't even contain parse_name and parse_interface functions where I did those modifications. So I guess I will leave this issue just like a warning "dont use spaces in your interface names". I know how ti fix it in Ansible 2.9.9 but I havent explored it in this completely different code that is here (it fails too though). |
@danpospisil, I could try and fix this for both current and previous versions :) |
Similar happens when using routeros_command and there is a interface list delimited with comma for example: community.network.routeros_command: ..
|
@zagi-tng this could also be caused by line wrapping. You could try adding |
I can reproduce the issue with commas too, looks like its splitting it into different commands on the comma. Fixed by wrapping the command in single quotes E.g.:
|
BTW, this issue is about community.routeros.facts, not about community.routeros.command. In any case, you seem to be supplying a string to the - community.routeros.command:
commands:
- put command here |
yes. that works.
|
I guess we can close this one ? |
I think we can. There's not much more we can do here I guess... |
SUMMARY
When an interface has a space in its name, the routeros_facts module will fail.
ISSUE TYPE
COMPONENT NAME
routeros
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Windows 10, Ubuntu WSL 1
STEPS TO REPRODUCE
EXPECTED RESULTS
No crash should occur
ACTUAL RESULTS
Ansible will crash - it extracts not the whole name when spaces are present in it
To fix this I have changed the extraction regexp in routeros_facts.py file:
function parse_name:
match = re.search(r'name=\"([\w\d\-\s]+)\"', data, re.M)
function parse_interface:
match = re.search(r'\sinterface=([\w\d\-\s]+[\w\d\-])\s', data, re.M)
The text was updated successfully, but these errors were encountered: