Commit graph

6 commits

Author SHA1 Message Date
Felix Fontein
d73eb1c144
Add module_utils and filters for quoting and unquoting (#53)
* Move splitting code to own file.

* Move list to dictionary code to quoting as well.

* Add quoting functionality.

* Add quoting filters.

* Add integration tests to CI.

* Fix bugs, increase coverage.

* Make parsing more strict.

* Extract function parse_argument_value from split_routeros_command to make proper parsing of WHERE possible.

* Adjust expected error message in integration tests.

* Simplify code and improve coverage.

* Add changelog fragment for WHERE strictness in api module.

* Add documenation.

* Fix typo.

* Add documentation references.

* Add example to api module which uses quote_argument_value.

* Fix bug, and add tests which prevent this in the future.

* Add more escape sequence tests.

* Make sure all control characters are quoted.
2021-10-12 00:44:40 +03:00
Felix Fontein
937aa0dbfa
Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#38)
* Replace ansible.module_utils._text by ansible.module_utils.common.text.converters.

* One more.
2021-06-27 09:53:45 +02:00
Renato Almeida de Oliveira
e5ad772703
Change to_text for to_native (#5) 2020-10-29 00:57:17 +03:00
Felix Fontein
6ccc2eab79 Add boilerplate (#108)
* Add boilerplate to doc_fragments and module_utils.

* Add boilerplate to unit tests.

* Add boilerplate to modules.
2020-10-26 15:18:40 +01:00
Renato Almeida de Oliveira
3634150468 routeros: Bug fix: Exception catching (#27)
* Bug fix: Exception catching

The function get_capabilities was failing to catch connections exceptions, what make an ugly output

OUTPUT BEFORE CHANGES:

The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routeros_comle>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routeros_comallz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routeros_com_module
    runpy.run_module(mod_name='ansible.modules.network.routeros.command', init_globals=None, run_name='__main__', a
  File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/modules/network/routeros/r7, in <module>
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/modules/network/routeros/r7, in main
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/routein run_commands
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/routen get_connection
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/routen get_capabilities
  File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/connection.py
ansible.module_utils.connection.ConnectionError: Failed to authenticate: Authentication failed.
fatal: [MK]: FAILED! => changed=false
  module_stderr: |-
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routerosmodule>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routerosnsiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-local-20843l7aphwz5/ansible-tmp-1588555470.4121525-264386939405924/AnsiballZ_routerosvoke_module
        runpy.run_module(mod_name='ansible.modules.network.routeros.command', init_globals=None, run_name='__main__
      File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
        fname, loader, pkg_name)
      File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
        mod_name, mod_fname, mod_loader, pkg_name)
      File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/modules/network/routere 187, in <module>
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/modules/network/routere 157, in main
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/r25, in run_commands
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/r5, in get_connection
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/network/r9, in get_capabilities
      File "/tmp/ansible_command_payload_XbsRY1/ansible_command_payload.zip/ansible/module_utils/connectio
    ansible.module_utils.connection.ConnectionError: Failed to authenticate: Authentication failed.
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

OUTPUT AFTER CHANGES

fatal: [MK]: FAILED! => changed=false
  msg: 'Failed to authenticate: Authentication failed.'

* Lint Fix

* changelog fragment

* changelog update

* to_text refactoring
2020-10-26 15:18:40 +01:00
John R Barker
bcfea39ddc Add networking (#1)
Initial commit of network content that was previously in community.general
2020-10-26 15:18:40 +01:00