-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
New module: routeros — manage MikroTik RouterOS #41155
Conversation
The test
The test
|
The test
|
I don't have any experience so far with network modules, so maybe I'm doing something really wrong ;) I've tried to use this module, but so far I always get timeouts. I'm using the following playbook: ---
- name: RouterOS test
hosts: router
gather_facts: no
tasks:
- routeros_command:
commands: /system routerboard print
host: 192.168.88.1
port: 22
transport: routeros
username: admin
password: xxx
register: output
- debug:
var: output My inventory: [router]
router ansible_host=192.168.88.1
[router:vars]
ansible_connection=network_cli
ansible_network_os=routeros
ansible_user=admin
ansible_remote_user=admin
ansible_ssh_pass=xxx When running
|
@felixfontein Thanks for testing it out! routeros:
hosts:
example:
ansible_host: 192.168.88.1
ansible_user: admin+cet
ansible_ssh_pass: ''
ansible_network_os: routeros
ansible_connection: network_cli And here is a sample playbook: ---
- hosts: example
gather_facts: no
connection: network_cli
tasks:
- routeros_command:
commands:
- /system resource print
register: output
- debug:
var: output Unfortunately this is the only way to disable console colours, you can't do it after you're logged in. I guess I could put it into the docs for this module, however it would be much better if Ansible could add the suffix all by itself. But I'm pretty new to Ansible myself and have not been able to figure out a way yet. I have tried doing it using an action plugin, but it does not seem to be called anymore when I set the |
I have figured it out. The action plugin now automatically appends |
Yes, adding I've tried your updated version (with the action plugin), but I still need to append I've tried tinkering with various things, and I'm not convinced there's anything we can do about it (without deeper changes in |
I made a little bit progress: if I copy the following lines from ansi_re = [
# check ECMA-48 Section 5.4 (Control Sequences)
re.compile(br'(\x1b\[\?1h\x1b=)'),
re.compile(br'((?:\x9b|\x1b\x5b)[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])'),
re.compile(br'\x08.')
] to terminal_initial_prompt = [
br'\x1bZ',
]
terminal_initial_answer = b'\x1b/Z' The router then sends |
The test
The test
The test
The test
The test
The test
The test
The test
|
The test
|
Using CLI in Ansible 2.6 | ||
================================================================================ | ||
|
||
Example CLI ``group_vars/ios.yml`` |
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.
I guess you should change ios.yml
to routeros.yml
;-)
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.
My bad, thanks! 🙂
@ganeshrn I've addressed all your comments, thank you for reviewing! |
@heuels @felixfontein Thank you! |
SUMMARY
For quite some time I have been seeing questions popping up on StackOverflow, official wiki and even here (#29333) to add native support for managing MikroTik RouterOS devices to Ansible. There have been several projects, but all of them either don't support the latest Ansible release or are long abandoned. This pull request implements a simple
network_cli
module to support RouterOS devices. I also plan to further support this module and add more commands and functionality to it in the future.ISSUE TYPE
COMPONENT NAME
routeros_command
ANSIBLE VERSION
ADDITIONAL INFORMATION