Commit Graph

59 Commits (ef42eaeaa1d463eae5c4788f9a35cd3d24580d92)

Author SHA1 Message Date
welchwilmerck af40d04247 bring comments and docs up-to-date for invoking hacking/test-module (#20940)
inside test-module, rundebug also needs to know interpreters
7 years ago
Sloane Hertel 113f92548a hacking/test-module: fix for python3 (#26194)
* make hacking/test-module compatible with python3
7 years ago
Michael De La Rue 56d33a2967 Fix hacking/test-module to allow running modules with pdb (#23339)
* Fix hacking/test-module to allow running modules with pdb

* add emacs autosave files to gitignore
7 years ago
Yujun Zhang 1f3755f86b Include error message when ansiballz_setup fails (#26127)
It is quite difficult to pinpoint what is wrong without it
7 years ago
Martyn Ranyard 014f33655c Allows for testing binary modules (#24857) 7 years ago
Allan ba39d1158c Update test-module (#20737)
* Update test-module

Ensuring invoke is assigned

Traceback (most recent call last):
  File "ansible/hacking/test-module", line 267, in <module>
    main()
  File "ansible/hacking/test-module", line 263, in main
    runtest(modfile, argspath, modname, module_style, interpreters)
  File "ansible/hacking/test-module", line 207, in runtest
    invoke = "%s%s" % (invoke, modfile)
UnboundLocalError: local variable 'invoke' referenced before assignment

* Update test-module

Made the change to only require a single if, making the function more 'DRY'.
8 years ago
Will Thames 082082857d Use the python used with test-module to run modules (#19591)
* Use ansible_python_interpreter to run modules

Use ansible_python_interpreter to run modules if
`-I ansible_python_interpreter` is set.

Remove unused default from `-I` help text.

* Update test-module to pep8 standards
8 years ago
Adrian Likins cf39a1abab test-module _ansible_selinux_special_fs arg added
modules need to have _ansible_selinux_special_fs passed in
as an arg, so add the default to the args.
8 years ago
Toshio Kuratomi 48a2773463 Find places where ziploader is used and change them to ansiballz so that people aren't confused when they google for information.information (#16715) 8 years ago
Toshio Kuratomi 2762f12f7f Remove the duplicate modstyle parameter 8 years ago
Toshio Kuratomi bdd73e31dc Have test-module clean up the local temp dir when it exits
Get test-module's debugger switch to do something useful with ziploader modules
8 years ago
Toshio Kuratomi 669f3dc3a8 Cleanup. Since we no longer pass a lock, we no longer need to create it 8 years ago
Toshio Kuratomi d78ba34cf0 We switched away from passing the lock via the arguments to modify_module
Need to fix test-module to not pass the lock either
8 years ago
Toshio Kuratomi dcc5dfdf81 Controller-side module caching.
This makes our recursive, ast.parse performance measures as fast as
pre-ziploader baseline.

Since this unittest isn't testing that the returned module data is
correct we don't need to worry about os.rename not having any module
data.  Should devise a separate test for the module and caching code
8 years ago
Toshio Kuratomi a330a24ccc Python2.6 fix for test-module 8 years ago
Toshio Kuratomi 4b0aa1214c Ziploader
* Ziploader proof of concept (jimi-c)

* Cleanups to proof of concept ziploader branch:

* python3 compatible base64 encoding
* zipfile compression (still need to enable toggling this off for
  systems without zlib support in python)
* Allow non-wildcard imports (still need to make this recusrsive so that
  we can have module_utils code that imports other module_utils code.)
* Better tracebacks: module filename is kept and module_utils directory
  is kept so that tracebacks show the real filenames that the errors
  appear in.

* Make sure we import modules that are used into the module_utils files that they are used in.

* Set ansible version in a more pythonic way for ziploader than we were doing in module replacer

* Make it possible to set the module compression as an inventory var

This may be necessary on systems where python has been compiled without
zlib compression.

* Refactoring of module_common code:

* module replacer only replaces values that make sense for that type of
  file (example: don't attempt to replace python imports if we're in
  a powershell module).
* Implement configurable shebang support for ziploader wrapper
* Implement client-side constants (for SELINUX_SPECIAL_FS and SYSLOG)
  via environment variable.
* Remove strip_comments param as we're never going to use it (ruins line
  numbering)

* Don't repeat ourselves about detecting REPLACER

* Add an easy way to debug

* Port test-module to the ziploader-aware modify_module()

* strip comments and blank lines from the wrapper so we send less over the wire.

* Comments cleanup

* Remember to output write the module line itself in powershell modules

* for line in lines strips the newlines so we have to add them back in
8 years ago
Alberto Gireud 52ded67db5 Update check mode argument 9 years ago
Toshio Kuratomi 4203850d1a Break apart a looped dependency to show a warning when parsing playbooks
Display a warning when a dict key is overwritten by pyyaml
Fixes #12888
9 years ago
Kevin Houdebert b8c9391d0c Change to python3 syntax 9 years ago
Toshio Kuratomi 53ae326603 Port some things in test-module to v2.
In particular, fix arg parsing

Fixes #11820
9 years ago
Abhijit Menon-Sen 8342cc6b61 Fix existing typo, remove trailing space added by PR commit 9 years ago
Will Thames b05485d4b3 Add options to control output and execution of test-module
test-module is useful but sometimes you want to edit the
result before running it to e.g. set a debug point.

Added a noexecute option (i.e. just create the module script, don't
run it) and an output option to choose the filename of the result.
9 years ago
Gerard Lynch 2f51f3bbc5 updated to use new loader 9 years ago
Brian Coca 95bf78d0e7 Merge pull request #11618 from halberom/test-module
hacking/test-module, updated to new location and non-classness of module_common
9 years ago
Gerard Lynch 3c7a502c50 updated to new location and non-classness of module_common 9 years ago
Brian Coca f146c7680f Merge pull request #10928 from gimoh/test-module-default-python
Use same interpreter for test-module and module it runs
9 years ago
Marc Abramowitz 3b0524e67d hacking/test-module: Style nit 9 years ago
Marc Abramowitz 5466ff8907 hacking/test-module: Deal with move of parse_kv 9 years ago
Marc Abramowitz ea6ec3bf2c Make test-module work in v2
- `jsonify` moved from `ansible.utils` to `ansible.parsing.utils.jsonify`
- I don't see `ansible.utils.parse_json` anymore so I used `json.loads`.
9 years ago
gimoh 5489d172de Use same interpreter for test-module and module it runs
Default python interpreter to the same interpreter the test-module
script is executed with.  This is so that the interpreter doesn't have
to be specified twice in the command when using non-default python
(e.g. ``/path/to/python ./hacking/test-module -I python=/path/to/python ...``)
9 years ago
Veres Lajos bf5d8ee678 typofixes - https://github.com/vlajos/misspell_fixer 10 years ago
Hector Acosta b8cbf1370f Add checkmode support for test-module script
Signed-off-by: Hector Acosta <hector.acosta@gmail.com>
10 years ago
Felix Kaiser 3b06ab84e3 Make test-module interpret --args='{...' as yaml 10 years ago
Matt Martz dbed05caec Support for -a to accept a file with test-module
If the CLI value for -a starts with an @, treat it like a file, and dump the contents into complex_args

This supports yaml or json.
11 years ago
Matt Martz e50c2bccb8 Add -I/--interpreter argument to test-module 11 years ago
Michael DeHaan d34a26e307 Undo an inadvertant revert from template changes so we still allow pythonic imports in module land. 11 years ago
James Tanner d154bf8781 Revert templating enhancements from 73dbab70 e6c28658 d409352c 9858b1f2 4587528b 9b1fe455 214b0b05 8d3db803 7f9504d1 5031104c 35cb9dc2 2bd8cb57 1e85c754 11 years ago
Michael DeHaan 9858b1f2f3 Enable imports to work on a snippet based system, allowing for instance a library of common EC2 functions
to be reused between modules.  See library/system/service and library/system/ping for initial examples.  Can
work the old way to just import 'basic', or can import the new way to import multiple pieces of code from
module_utils/.
11 years ago
Nicolas Grilly 75ceb80572 Escape args injected in new style modules 11 years ago
Michael DeHaan af2fb56a10 Changes to allow WANT_JSON to allow JSON to non-Python modules 11 years ago
Michael DeHaan b3eb1f32e3 update hacking/test_module script to be aware of complex arguments, though it does not pass them. 12 years ago
Les Aker ee274b5816 fixed shebang in hacking test-module 12 years ago
Stephen Fromm 6a68d3813f Set LANG in module_common.py
Add constant DEFAULT_MODULE_LANG that defaults to C.  Can be set via
environment variable ANSIBLE_MODULE_LANG or configuration variable
module_lang.  Updated test-module to have same behavior.
12 years ago
Stephen Fromm 06e54c0b97 Add ability to specify syslog facility for modules
Update constants.py so that one can specify environmental variable
ANSIBLE_SYSLOG_FACILITY or syslog_facility in ansible.cfg to define
the syslog facility to use.  Alternatively, you can specify
ansible_syslog_facility in inventory.  Runner now replaces
the syslog facility in the openlog() call with the default or
the injected variables ansible_syslog_facility.

This also updates hacking/test-module to behave similarly.
12 years ago
Michael DeHaan ce01c3f7e7 Allow unicode transfer by not base64 encoding. Also: faster 12 years ago
Michael DeHaan 738cea9c93 small tweaks to --help for hacking/test-module 12 years ago
Michael DeHaan fc96b88205 Teach the test-module script about the new way MODULE_ARGS works in new-style modules. 12 years ago
bradobro e8583833a7 test-module uses optparse with --debugger
Refactored hacking/test-module

1. uses optparse

2. has --debugger option

tested only with pdb on Python 2.7
12 years ago
bradobro ade0233d57 Refactoring test-module to be more like ansible. 12 years ago
Michael DeHaan d0f4358730 Port the copy module over to the new "common module" logic. 12 years ago