diff options
author | Matt Martz <matt@sivel.net> | 2013-12-30 14:32:13 -0600 |
---|---|---|
committer | Matt Martz <matt@sivel.net> | 2013-12-30 14:53:32 -0600 |
commit | e50c2bccb88280ae37f39c755b0ef8bdb7fd79d8 (patch) | |
tree | 7de5e423add13fdf0536b90477bf902ec6f26fce /hacking/test-module | |
parent | c45f16623558aafdd3ae67dfcabecc40a5142dce (diff) | |
download | ansible-e50c2bccb88280ae37f39c755b0ef8bdb7fd79d8.tar.gz |
Add -I/--interpreter argument to test-module
Diffstat (limited to 'hacking/test-module')
-rwxr-xr-x | hacking/test-module | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/hacking/test-module b/hacking/test-module index 24c04900b2..cf4b475390 100755 --- a/hacking/test-module +++ b/hacking/test-module @@ -56,6 +56,9 @@ def parse(): help="module argument string") parser.add_option('-D', '--debugger', dest='debugger', help="path to python debugger (e.g. /usr/bin/pdb)") + parser.add_option('-I', '--interpreter', dest='interpreter', + help="path to interpeter to use for this module (e.g. ansible_python_interpreter=/usr/bin/python)", + metavar='INTERPRETER_TYPE=INTERPRETER_PATH') options, args = parser.parse_args() if not options.module_path: parser.print_help() @@ -74,7 +77,7 @@ def write_argsfile(argstring, json=False): argsfile.close() return argspath -def boilerplate_module(modfile, args): +def boilerplate_module(modfile, args, interpreter): """ simulate what ansible does with new style modules """ #module_fh = open(modfile) @@ -87,6 +90,16 @@ def boilerplate_module(modfile, args): complex_args = {} inject = {} + if interpreter: + if '=' not in interpreter: + print 'interpeter must by in the form of ansible_python_interpreter=/usr/bin/python' + sys.exit(1) + interpreter_type, interpreter_path = interpreter.split('=') + if not interpreter_type.startswith('ansible_'): + interpreter_type = 'ansible_%s' % interpreter_type + if not interpreter_type.endswith('_interpreter'): + interpreter_type = '%s_interpreter' % interpreter_type + inject[interpreter_type] = interpreter_path (module_data, module_style, shebang) = replacer.modify_module( modfile, complex_args, @@ -144,7 +157,7 @@ def rundebug(debugger, modfile, argspath): def main(): options, args = parse() - (modfile, module_style) = boilerplate_module(options.module_path, options.module_args) + (modfile, module_style) = boilerplate_module(options.module_path, options.module_args, options.interpreter) argspath=None if module_style != 'new': |