Added recommendation about module name (#49540)

* Added recommendation about module name

Added general guidelines for naming a module.

Fixes: #19665

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/49523/head
Abhijeet Kasurde 6 years ago committed by Sandra McCann
parent 49009879b9
commit 287a42eba0

@ -32,6 +32,7 @@ General guidelines & tips
=========================
* Each module should be self-contained in one file, so it can be be auto-transferred by Ansible.
* Module name MUST use underscores instead of hyphens or spaces as a word separator. Using hyphens and spaces will prevent Ansible from importing your module.
* Always use the ``hacking/test-module`` script when developing modules - it will warn you about common pitfalls.
* If you have a local module that returns facts specific to your installations, a good name for this module is ``site_facts``.
* Eliminate or minimize dependencies. If your module has dependencies, document them at the top of the module file and raise JSON error messages when dependency import fails.
@ -85,6 +86,7 @@ Importing and using shared code
HAS_LIB = False
LIB_IMP_ERR = traceback.format_exc()
Then in ``main()``, just after the argspec, do
.. code-block:: python
@ -93,6 +95,7 @@ Importing and using shared code
module.fail_json(msg=missing_required_lib("foo"),
exception=LIB_IMP_ERR)
And document the dependency in the ``requirements`` section of your module's :ref:`documentation_block`.
.. _module_failures:

Loading…
Cancel
Save