From 28b9f71640ca945ded810fc149dfc12d8123188b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Posp=C3=AD=C5=A1ek?= Date: Mon, 22 Jul 2019 21:58:13 +0200 Subject: [PATCH] remove ambiguity: use "my_test" as module name (#59335) Naming a module "something_module" is misleading (see below). Let's drop the "_module" part of the module name on the developing_modules_general page. --- .../dev_guide/developing_modules_general.rst | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/docsite/rst/dev_guide/developing_modules_general.rst b/docs/docsite/rst/dev_guide/developing_modules_general.rst index ce461d58c99..cfc82c2abda 100644 --- a/docs/docsite/rst/dev_guide/developing_modules_general.rst +++ b/docs/docsite/rst/dev_guide/developing_modules_general.rst @@ -52,7 +52,7 @@ Starting a new module To create a new module: 1. Navigate to the correct directory for your new module: ``$ cd lib/ansible/modules/cloud/azure/`` -2. Create your new module file: ``$ touch my_new_test_module.py`` +2. Create your new module file: ``$ touch my_test.py`` 3. Paste the content below into your new module file. It includes the :ref:`required Ansible format and documentation ` and some example code. 4. Modify and extend the code to do what you want your new module to do. See the :ref:`programming tips ` and :ref:`Python 3 compatibility ` pages for pointers on writing clean, concise module code. @@ -71,19 +71,19 @@ To create a new module: DOCUMENTATION = ''' --- - module: my_sample_module + module: my_test - short_description: This is my sample module + short_description: This is my test module version_added: "2.4" description: - - "This is my longer description explaining my sample module" + - "This is my longer description explaining my test module" options: name: description: - - This is the message to send to the sample module + - This is the message to send to the test module required: true new: description: @@ -100,18 +100,18 @@ To create a new module: EXAMPLES = ''' # Pass in a message - name: Test with a message - my_new_test_module: + my_test: name: hello world # pass in a message and have changed true - name: Test with a message and changed output - my_new_test_module: + my_test: name: hello world new: true # fail the module - name: Test failure of the module - my_new_test_module: + my_test: name: fail me ''' @@ -121,7 +121,7 @@ To create a new module: type: str returned: always message: - description: The output message that the sample module generates + description: The output message that the test module generates type: str returned: always ''' @@ -214,7 +214,7 @@ If your 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 -m ansible.modules.cloud.azure.my_new_test_module /tmp/args.json`` + ``$ python -m ansible.modules.cloud.azure.my_test /tmp/args.json`` This should return output like this: @@ -235,7 +235,7 @@ The next step in testing your new module is to consume it with an Ansible playbo hosts: localhost tasks: - name: run the new module - my_new_test_module: + my_test: name: 'hello' new: true register: testout @@ -274,7 +274,7 @@ You can add unit tests for your module in ``./test/units/modules``. You must fir To run pytest against a single test module, you can do the following (provide the path to the test module appropriately): ``$ pytest -r a --cov=. --cov-report=html --fulltrace --color yes -test/units/modules/.../test/my_new_test_module.py`` +test/units/modules/.../test/my_test.py`` Contributing back to Ansible ============================