|
|
|
|
@ -48,8 +48,8 @@ the 'command' module could already be used to do this.
|
|
|
|
|
|
|
|
|
|
Reading the modules that come with Ansible (linked above) is a great way to learn how to write
|
|
|
|
|
modules. Keep in mind, though, that some modules in Ansible's source tree are internalisms,
|
|
|
|
|
so look at :ref:`service` or :ref:`yum`, and don't stare too close into things like :ref:`async_wrapper` or
|
|
|
|
|
you'll turn to stone. Nobody ever executes :ref:`async_wrapper` directly.
|
|
|
|
|
so look at :ref:`service` or :ref:`yum`, and don't stare too close into things like ``async_wrapper`` or
|
|
|
|
|
you'll turn to stone. Nobody ever executes ``async_wrapper`` directly.
|
|
|
|
|
|
|
|
|
|
Ok, let's get going with an example. We'll use Python. For starters, save this as a file named :file:`timetest.py`::
|
|
|
|
|
|
|
|
|
|
@ -538,11 +538,11 @@ When you look into the debug_dir you'll see a directory structure like this::
|
|
|
|
|
that are passed to the module, this is the file to do it in.
|
|
|
|
|
|
|
|
|
|
* The :file:`ansible` directory contains code from
|
|
|
|
|
:module:`ansible.module_utils` that is used by the module. Ansible includes
|
|
|
|
|
:mod:`ansible.module_utils` that is used by the module. Ansible includes
|
|
|
|
|
files for any :`module:`ansible.module_utils` imports in the module but not
|
|
|
|
|
no files from any other module. So if your module uses
|
|
|
|
|
:module:`ansible.module_utils.url` Ansible will include it for you, but if
|
|
|
|
|
your module includes :module:`requests` then you'll have to make sure that
|
|
|
|
|
:mod:`ansible.module_utils.url` Ansible will include it for you, but if
|
|
|
|
|
your module includes :mod:`requests` then you'll have to make sure that
|
|
|
|
|
the python requests library is installed on the system before running the
|
|
|
|
|
module. You can modify files in this directory if you suspect that the
|
|
|
|
|
module is having a problem in some of this boilerplate code rather than in
|
|
|
|
|
@ -566,7 +566,7 @@ module file and test that the real module works via :command:`ansible` or
|
|
|
|
|
The wrapper provides one more subcommand, ``excommunicate``. This
|
|
|
|
|
subcommand is very similar to ``execute`` in that it invokes the exploded
|
|
|
|
|
module on the arguments in the :file:`args`. The way it does this is
|
|
|
|
|
different, however. ``excommunicate`` imports the :function:`main`
|
|
|
|
|
different, however. ``excommunicate`` imports the :func:`main`
|
|
|
|
|
function from the module and then calls that. This makes excommunicate
|
|
|
|
|
execute the module in the wrapper's process. This may be useful for
|
|
|
|
|
running the module under some graphical debuggers but it is very different
|
|
|
|
|
@ -575,7 +575,7 @@ module file and test that the real module works via :command:`ansible` or
|
|
|
|
|
with Ansible normally. Those are not bugs in the module; they're
|
|
|
|
|
limitations of ``excommunicate``. Use at your own risk.
|
|
|
|
|
|
|
|
|
|
.. _module_paths
|
|
|
|
|
.. _module_paths:
|
|
|
|
|
|
|
|
|
|
Module Paths
|
|
|
|
|
````````````
|
|
|
|
|
|