New module: routeros — manage MikroTik RouterOS (#41155)

* Implement initial RouterOS support

* Correct matchers for license prompts

* Documentation updates & mild refactor

* Remove one last Cisco function

* Sanity test fixes

* Move imports to the beginning

* Remove authorize property

* Handle ANSI codes

* Revert to_lines function

* CR fixes

* test(routeros): add unit tests

* Added another test (with ANSI colors and banner in fixture).

* Ignore CRLF line endings in system_package_print file

* fix: review by ganeshrn
This commit is contained in:
Egor Zaitsev 2018-07-30 07:58:03 +03:00 committed by Ganesh Nalawade
commit 249a6aae22
15 changed files with 941 additions and 27 deletions

View file

@ -15,38 +15,41 @@ Some Ansible Network platforms support multiple connection types, privilege esca
platform_ironware
platform_junos
platform_nxos
platform_routeros
.. _settings_by_platform:
Settings by Platform
================================
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
|.. | | ``ansible_connection:`` settings available |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Network OS | ``ansible_network_os:`` | network_cli | netconf | httpapi | local |
+==================+=========================+======================+======================+==================+==================+
| Arista EOS* | ``eos`` | in v. >=2.5 | N/A | in v. >=2.6 | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco ASA | ``asa`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco IOS* | ``ios`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco IOS XR* | ``iosxr`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco NX-OS* | ``nxos`` | in v. >=2.5 | N/A | in v. >=2.6 | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Extreme IronWare | ``ironware`` | in v. >=2.5 | N/A | N/A | in v. >=2.5 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| F5 BIG-IP | N/A | N/A | N/A | N/A | in v. >=2.0 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| F5 BIG-IQ | N/A | N/A | N/A | N/A | in v. >=2.0 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Junos OS* | ``junos`` | in v. >=2.5 | in v. >=2.5 | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Nokia SR OS | ``sros`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| VyOS* | ``vyos`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+------------------+-------------------------+----------------------+----------------------+------------------+------------------+
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
|.. | | ``ansible_connection:`` settings available |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Network OS | ``ansible_network_os:`` | network_cli | netconf | httpapi | local |
+===================+=========================+======================+======================+==================+==================+
| Arista EOS* | ``eos`` | in v. >=2.5 | N/A | in v. >=2.6 | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco ASA | ``asa`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco IOS* | ``ios`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco IOS XR* | ``iosxr`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Cisco NX-OS* | ``nxos`` | in v. >=2.5 | N/A | in v. >=2.6 | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Extreme IronWare | ``ironware`` | in v. >=2.5 | N/A | N/A | in v. >=2.5 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| F5 BIG-IP | N/A | N/A | N/A | N/A | in v. >=2.0 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| F5 BIG-IQ | N/A | N/A | N/A | N/A | in v. >=2.0 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Junos OS* | ``junos`` | in v. >=2.5 | in v. >=2.5 | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| MikroTik RouterOS | ``routeros`` | in v. >=2.7 | N/A | N/A | N/A |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| Nokia SR OS | ``sros`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
| VyOS* | ``vyos`` | in v. >=2.5 | N/A | N/A | in v. >=2.4 |
+-------------------+-------------------------+----------------------+----------------------+------------------+------------------+
`*` Maintained by Ansible Network Team

View file

@ -0,0 +1,65 @@
.. _routeros_platform_options:
***************************************
RouterOS Platform Options
***************************************
.. contents:: Topics
Connections Available
================================================================================
+---------------------------+-----------------------------------------------+
|.. | CLI |
+===========================+===============================================+
| **Protocol** | SSH |
+---------------------------+-----------------------------------------------+
| | **Credentials** | | uses SSH keys / SSH-agent if present |
| | | | accepts ``-u myuser -k`` if using password |
+---------------------------+-----------------------------------------------+
| **Indirect Access** | via a bastion (jump host) |
+---------------------------+-----------------------------------------------+
| | **Connection Settings** | | ``ansible_connection: network_cli`` |
| | | | |
| | | | |
+---------------------------+-----------------------------------------------+
| | **Enable Mode** | | not supported by RouterOS |
| | (Privilege Escalation) | | |
+---------------------------+-----------------------------------------------+
| **Returned Data Format** | ``stdout[0].`` |
+---------------------------+-----------------------------------------------+
Using CLI in Ansible 2.6
================================================================================
Example CLI ``group_vars/routeros.yml``
---------------------------------------
.. code-block:: yaml
ansible_connection: network_cli
ansible_network_os: routeros
ansible_user: myuser
ansible_ssh_pass: !vault...
ansible_become: yes
ansible_become_method: enable
ansible_become_pass: !vault...
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords via environment variables.
Example CLI Task
----------------
.. code-block:: yaml
- name: Display resource statistics (routeros)
routeros_command:
commands: /system resource print
register: routeros_resources
when: ansible_network_os == 'routeros'
.. include:: shared_snippets/SSH_warning.txt