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.
pull/50901/head
Tomáš Pospíšek 5 years ago committed by Alicia Cozine
parent 9ff26a4a22
commit 28b9f71640

@ -52,7 +52,7 @@ Starting a new module
To create a new module: To create a new module:
1. Navigate to the correct directory for your new module: ``$ cd lib/ansible/modules/cloud/azure/`` 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 <developing_modules_documenting>` and some example code. 3. Paste the content below into your new module file. It includes the :ref:`required Ansible format and documentation <developing_modules_documenting>` 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 <developing_modules_best_practices>` and :ref:`Python 3 compatibility <developing_python_3>` pages for pointers on writing clean, concise module code. 4. Modify and extend the code to do what you want your new module to do. See the :ref:`programming tips <developing_modules_best_practices>` and :ref:`Python 3 compatibility <developing_python_3>` pages for pointers on writing clean, concise module code.
@ -71,19 +71,19 @@ To create a new module:
DOCUMENTATION = ''' 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" version_added: "2.4"
description: description:
- "This is my longer description explaining my sample module" - "This is my longer description explaining my test module"
options: options:
name: name:
description: description:
- This is the message to send to the sample module - This is the message to send to the test module
required: true required: true
new: new:
description: description:
@ -100,18 +100,18 @@ To create a new module:
EXAMPLES = ''' EXAMPLES = '''
# Pass in a message # Pass in a message
- name: Test with a message - name: Test with a message
my_new_test_module: my_test:
name: hello world name: hello world
# pass in a message and have changed true # pass in a message and have changed true
- name: Test with a message and changed output - name: Test with a message and changed output
my_new_test_module: my_test:
name: hello world name: hello world
new: true new: true
# fail the module # fail the module
- name: Test failure of the module - name: Test failure of the module
my_new_test_module: my_test:
name: fail me name: fail me
''' '''
@ -121,7 +121,7 @@ To create a new module:
type: str type: str
returned: always returned: always
message: message:
description: The output message that the sample module generates description: The output message that the test module generates
type: str type: str
returned: always 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`` development) activate it: ``$ . venv/bin/activate``
- Setup the environment for development: ``$ . hacking/env-setup`` - Setup the environment for development: ``$ . hacking/env-setup``
- Run your test module locally and directly: - 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: 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 hosts: localhost
tasks: tasks:
- name: run the new module - name: run the new module
my_new_test_module: my_test:
name: 'hello' name: 'hello'
new: true new: true
register: testout 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): 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 ``$ 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 Contributing back to Ansible
============================ ============================

Loading…
Cancel
Save