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

[WIP] Add RouterOS API support to routeros_command module #44688

Open
wants to merge 3 commits into
base: devel
from

Conversation

Projects
None yet
5 participants
@heuels
Contributor

heuels commented Aug 26, 2018

SUMMARY

This pull request adds support for issuing commands via RouterOS API and local connection type. This is required because of several problems with network_cli implementation:

  • The output of the command gets wrapped by the RouterOS console and it sometimes makes the command itself appear in the output.
  • The output is dependent on the terminal width. If one tries to set terminal width to a very large number, each line of the output will be equally distributed among the available width.
  • Some commands with verbose output sometimes do not return values (like /ip firewall filter print).

Why use a provider? Because RouterOS has a weird and non-standard API. The choice was either to use connection: local and a provider or create a new module solely for RouterOS API support. After a discussion with ganeshrn in the original routeros_command PR it was decided it would be better to use the former.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • lib/ansible/module_utils/network/routeros/routeros.py
  • lib/ansible/modules/network/routeros/routeros_command.py
ANSIBLE VERSION
ansible 2.7.0.dev0 (routeros_api 790c0bf2b3) last updated 2018/08/26 11:31:57 (GMT +300)
  config file = None
  configured module search path = ['/Users/heuels/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/heuels/GitHub/ansible/lib/ansible
  executable location = /Users/heuels/GitHub/ansible/bin/ansible
  python version = 3.6.5 (default, Jun 19 2018, 01:03:38) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
ADDITIONAL INFORMATION

@ansibot

This comment has been minimized.

@heuels heuels force-pushed the heuels:routeros_api branch to e872864 Aug 26, 2018

@ansibot ansibot removed the needs_rebase label Aug 26, 2018

@felixfontein

This comment has been minimized.

Contributor

felixfontein commented Aug 26, 2018

@heuels Cool! I'll try it out later; I'm looking forward to be able to use this one as well! ;)

@ansibot

This comment has been minimized.

Contributor

ansibot commented Aug 26, 2018

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/module_utils/network/routeros/routeros.py:43:0: ImportError: No module named utils.display

The test ansible-test sanity --test import --python 2.7 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:43:0: ImportError: No module named utils.display
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ImportError: No module named utils.display

The test ansible-test sanity --test import --python 3.5 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:43:0: ImportError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ImportError: No module named 'ansible.utils'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:43:0: ModuleNotFoundError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ModuleNotFoundError: No module named 'ansible.utils'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:43:0: ModuleNotFoundError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ModuleNotFoundError: No module named 'ansible.utils'

The test ansible-test sanity --test validate-modules [explain] failed with 3 errors:

lib/ansible/modules/network/routeros/routeros_command.py:0:0: E322 "provider" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/network/routeros/routeros_command.py:0:0: E324 Value for "default" from the argument_spec ('cli') for "transport" does not match the documentation (None)
lib/ansible/modules/network/routeros/routeros_command.py:0:0: E326 Value for "choices" from the argument_spec (['api', 'cli']) for "transport" does not match the documentation ([])

click here for bot help

@ansibot ansibot added the ci_verified label Aug 26, 2018

@heuels

This comment has been minimized.

Contributor

heuels commented Aug 26, 2018

@felixfontein I'm looking forward to it! I still need to verify that SSL connection works but the basic stuff is ready :)

@bcoca bcoca removed the needs_triage label Aug 27, 2018

@ansibot ansibot added the stale_ci label Sep 4, 2018

@shaders

This comment has been minimized.

This will split incorrectly parameter like: comment="Test String" into:
comment:Test
String: none

Should we use:
split_command = shlex.split(command)
?

@shaders

This comment has been minimized.

shaders commented Sep 12, 2018

Please see: 663cdb5#r30480308

@ansibot

This comment has been minimized.

Contributor

ansibot commented Sep 17, 2018

@heuels

This comment has been minimized.

Contributor

heuels commented Sep 17, 2018

@shaders, thank you! I've addressed your comment in b79c04a.

@ansibot

This comment has been minimized.

Contributor

ansibot commented Sep 17, 2018

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/module_utils/network/routeros/routeros.py:44:0: ImportError: No module named utils.display

The test ansible-test sanity --test import --python 2.7 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:44:0: ImportError: No module named utils.display
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ImportError: No module named utils.display

The test ansible-test sanity --test import --python 3.5 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:44:0: ImportError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ImportError: No module named 'ansible.utils'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:44:0: ModuleNotFoundError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ModuleNotFoundError: No module named 'ansible.utils'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 2 errors:

lib/ansible/module_utils/network/routeros/routeros.py:44:0: ModuleNotFoundError: No module named 'ansible.utils'
lib/ansible/modules/network/routeros/routeros_command.py:133:0: ModuleNotFoundError: No module named 'ansible.utils'

The test ansible-test sanity --test validate-modules [explain] failed with 3 errors:

lib/ansible/modules/network/routeros/routeros_command.py:0:0: E322 "provider" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/network/routeros/routeros_command.py:0:0: E324 Value for "default" from the argument_spec ('cli') for "transport" does not match the documentation (None)
lib/ansible/modules/network/routeros/routeros_command.py:0:0: E326 Value for "choices" from the argument_spec (['api', 'cli']) for "transport" does not match the documentation ([])

click here for bot help

@ansibot ansibot added the stale_ci label Sep 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment