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 <module>
        from ansible.module_utils.basic import AnsibleModule
      File "~/ansible/lib/ansible/module_utils/basic.py", line 78, in <module>
        import tempfile
      File "~/ansible/lib/ansible/modules/files/tempfile.py", line 69, in <module>
        from tempfile import mkstemp, mkdtemp
    ImportError: cannot import name 'mkstemp'
pull/45879/head
Pilou 6 years ago committed by ansibot
parent 1b0c4fde86
commit 60160c1e90

@ -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:

@ -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"}}'

Loading…
Cancel
Save