ansible/test/sanity/validate-modules
Will Thames dce445f956 Improve error message for module validation (#19501)
Print out the data that fails to validate when doing
schema checking on modules

This allows easier interpretation of error messages.

From:

```
ERROR: DOCUMENTATION.notes.2: expected basestring
```

To:

```
ERROR: DOCUMENTATION.notes.2: expected basestring @ data['notes'][2].
Got {"As with C(include) this task can be static or dynamic, If static
it implies that it won't need templating nor loops nor conditionals and
will show included tasks in the --list options. Ansible will try to
autodetect what is needed, but you can set `static": 'yes|no` at task
level to control this.'}
```
2016-12-19 08:49:18 +00:00
..
__init__.py
module_args.py
README.rst Add a check for type() instead of isinstance() (#18439) 2016-11-10 14:06:14 -08:00
schema.py
skip.txt Remove remnants of obsolete fireball mode. 2016-12-09 16:56:34 -07:00
test_validate_modules_regex.py Add a check for type() instead of isinstance() (#18439) 2016-11-10 14:06:14 -08:00
utils.py
validate-modules Improve error message for module validation (#19501) 2016-12-19 08:49:18 +00:00

validate-modules

Python program to help test or validate Ansible modules.

Originally developed by Matt Martz (@sivel)

Usage

cd /path/to/ansible/source
source hacking/env-setup
test/sanity/validate-modules/validate-modules /path/to/modules

Help

usage: validate-modules [-h] [-w] [--exclude EXCLUDE] modules

positional arguments:
  modules            Path to module or module directory

optional arguments:
  -h, --help         show this help message and exit
  -w, --warnings     Show warnings
  --exclude EXCLUDE  RegEx exclusion pattern

Current Validations

Modules

Errors

  1. Interpreter line is not #!/usr/bin/python
  2. main() not at the bottom of the file
  3. Module does not import ansible.module_utils.basic
  4. Missing DOCUMENTATION
  5. Documentation is invalid YAML
  6. Invalid schema for DOCUMENTATION
  7. Missing EXAMPLES
  8. Invalid Python Syntax
  9. Tabbed indentation
  10. Use of sys.exit() instead of exit_json or fail_json
  11. Missing GPLv3 license header in module
  12. PowerShell module missing WANT_JSON
  13. PowerShell module missing POWERSHELL_COMMON
  14. New modules have the correct version_added
  15. New arguments have the correct version_added
  16. Modules should not import requests, instead use ansible.module_utils.urls
  17. Missing RETURN for new modules
  18. Use of type() for type comparison instead of isinstance()

Warnings

  1. Try/Except HAS_ expression missing
  2. Missing RETURN for existing modules
  3. import json found
  4. Module contains duplicate globals from basic.py

Module Directories (Python Packages)

  1. Missing __init__.py