Skip to content
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

test-module cannot parse complex arguments that contain characters like : or / #26636

Closed
chbndrhnns opened this issue Jul 11, 2017 · 2 comments
Closed
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. traceback This issue/PR includes a traceback.

Comments

@chbndrhnns
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hacking/test-module

ANSIBLE VERSION
ansible 2.4.0 (3-access-to-networks 6a61aecebc) last updated 2017/07/11 11:36:57 (GMT +200)
  config file = None
  configured module search path = [u'/Users/jo/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/jo/repos/ansible/lib/ansible
  executable location = /Users/jo/repos/ansible/bin/ansible
  python version = 2.7.13 (default, Dec 18 2016, 07:03:39) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
CONFIGURATION

None

OS / ENVIRONMENT

Mac OS X 10.12

SUMMARY

Using hacking/test-module to run one of my modules locally fails when I supply arguments that contain some special characters like:

  • :
  • /
STEPS TO REPRODUCE

Have an arbitrary module and use the test-module command:

/hacking/test-module -m contrail_network.py -a "{"auth": [{"endpoint": "localhost:8082"},{}]}"
EXPECTED RESULTS

Correct parsing of the parameters

ACTUAL RESULTS

Parsing error

Traceback (most recent call last):
  File "../../../../../hacking/test-module", line 266, in <module>
    main()
  File "../../../../../hacking/test-module", line 247, in main
    (modfile, modname, module_style) = boilerplate_module(options.module_path, options.module_args, interpreters, options.check, options.filename)
  File "../../../../../hacking/test-module", line 134, in boilerplate_module
    complex_args = utils_vars.combine_vars(complex_args, loader.load(args))
  File "/Users/jo/repos/ansible/lib/ansible/parsing/dataloader.py", line 115, in load
    self._handle_error(yaml_exc, file_name, show_content)
  File "/Users/jo/repos/ansible/lib/ansible/parsing/dataloader.py", line 221, in _handle_error
    raise AnsibleParserError(YAML_SYNTAX_ERROR, obj=err_obj, show_content=show_content, orig_exc=yaml_exc)
ansible.errors.AnsibleParserError: Syntax Error while loading YAML.


The error appears to have been in '<string>': line 1, column 29, but may
be elsewhere in the file depending on the exact syntax problem.

exception type: <class 'yaml.scanner.ScannerError'>
exception: while scanning a plain scalar
  in "<byte string>", line 1, column 20
found unexpected ':'
  in "<byte string>", line 1, column 29
make: *** [test-1] Error 1
@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 11, 2017
@chbndrhnns
Copy link
Author

chbndrhnns commented Jul 11, 2017

In the gitter channel I came across the idea to use single quotes for the whole thing which works.

So, if that's the intended, then the README.md is wrong where the example is like this:

Use:

$ ./hacking/test-module -m module
-a "{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}"

Still, the child value in Python is then a string, although I expected a nested dictionary.

@ryansb ryansb added test This PR relates to tests. and removed needs_triage Needs a first human triage before being processed. labels Jul 11, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@ansibot ansibot added the traceback This issue/PR includes a traceback. label May 28, 2018
@sivel
Copy link
Member

sivel commented Jun 21, 2018

This issue has been resolved in the documentation via #26667

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Jun 21, 2018
@ansible ansible locked and limited conversation to collaborators Jun 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. traceback This issue/PR includes a traceback.
Projects
None yet
Development

No branches or pull requests

4 participants