From 60160c1e904462290e1214f6237060eab25b14bf Mon Sep 17 00:00:00 2001 From: Pilou Date: Wed, 19 Sep 2018 16:10:55 +0200 Subject: [PATCH] doc: exercising module code locally: update cmd (#45697) The documented way to execute module code locally wasn't always working: $ python ./lib/ansible/modules/files/file.py <<< '{"ANSIBLE_MODULE_ARGS": {}}' Traceback (most recent call last): File "./lib/ansible/modules/files/file.py", line 177, in from ansible.module_utils.basic import AnsibleModule File "~/ansible/lib/ansible/module_utils/basic.py", line 78, in import tempfile File "~/ansible/lib/ansible/modules/files/tempfile.py", line 69, in from tempfile import mkstemp, mkdtemp ImportError: cannot import name 'mkstemp' --- docs/docsite/rst/dev_guide/developing_modules_general.rst | 2 +- test/integration/targets/test_infra/runme.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docsite/rst/dev_guide/developing_modules_general.rst b/docs/docsite/rst/dev_guide/developing_modules_general.rst index 9a7823bf038..c7617c09883 100644 --- a/docs/docsite/rst/dev_guide/developing_modules_general.rst +++ b/docs/docsite/rst/dev_guide/developing_modules_general.rst @@ -211,7 +211,7 @@ If you module does not need to target a remote host, you can quickly and easily development) activate it: ``$ . venv/bin/activate`` - Setup the environment for development: ``$ . hacking/env-setup`` - Run your test module locally and directly: - ``$ python ./my_new_test_module.py /tmp/args.json`` + ``$ python -m ansible.modules.cloud.azure.my_new_test_module /tmp/args.json`` This should return output something like this: diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index be3809f95be..caa33fff3b5 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -25,3 +25,6 @@ echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 # ensure test-module script works well PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py" ../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)" + +# ensure exercising module code locally works +python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'