mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Refactor, add a TOC
This commit is contained in:
parent
f647c1d74c
commit
bed35095be
2 changed files with 73 additions and 59 deletions
60
doc/topics/development/modules/developing.rst
Normal file
60
doc/topics/development/modules/developing.rst
Normal file
|
@ -0,0 +1,60 @@
|
|||
======================
|
||||
Developing New Modules
|
||||
======================
|
||||
|
||||
Interactive Debugging
|
||||
=====================
|
||||
|
||||
Sometimes debugging with ``print()`` and extra logs sprinkled everywhere is not
|
||||
the best strategy.
|
||||
|
||||
IPython is a helpful debug tool that has an interactive python environment
|
||||
which can be embedded in python programs.
|
||||
|
||||
First the system will require IPython to be installed.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Debian
|
||||
apt-get install ipython
|
||||
|
||||
# Arch Linux
|
||||
pacman -Syu ipython2
|
||||
|
||||
# RHEL/CentOS (via EPEL)
|
||||
yum install python-ipython
|
||||
|
||||
|
||||
Now, in the troubling python module, add the following line at a location where
|
||||
the debugger should be started:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
test = 'test123'
|
||||
import IPython; IPython.embed_kernel()
|
||||
|
||||
After running a Salt command that hits that line, the following will show up in
|
||||
the log file:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
[CRITICAL] To connect another client to this kernel, use:
|
||||
[IPKernelApp] --existing kernel-31271.json
|
||||
|
||||
Now on the system that invoked ``embed_kernel``, run the following command from
|
||||
a shell:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# NOTE: use ipython2 instead of ipython for Arch Linux
|
||||
ipython console --existing
|
||||
|
||||
This provides a console that has access to all the vars and functions, and even
|
||||
supports tab-completion.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
print(test)
|
||||
test123
|
||||
|
||||
To exit IPython and continue running Salt, press ``Ctrl-d`` to logout.
|
|
@ -10,6 +10,17 @@ The most commonly used modular systems are execution modules and states. But
|
|||
the modular systems extend well beyond the more easily exposed components
|
||||
and are often added to Salt to make the complete system more flexible.
|
||||
|
||||
Additional Information
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
developing
|
||||
dunder_dictionaries
|
||||
|
||||
|
||||
Loading Modules
|
||||
===============
|
||||
|
||||
|
@ -140,65 +151,6 @@ For a list of all built in execution modules, click :ref:`here
|
|||
For information on writing execution modules, see :ref:`this page
|
||||
<writing-execution-modules>`.
|
||||
|
||||
|
||||
Interactive Debugging
|
||||
=====================
|
||||
|
||||
Sometimes debugging with ``print()`` and extra logs sprinkled everywhere is not
|
||||
the best strategy.
|
||||
|
||||
IPython is a helpful debug tool that has an interactive python environment
|
||||
which can be embedded in python programs.
|
||||
|
||||
First the system will require IPython to be installed.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Debian
|
||||
apt-get install ipython
|
||||
|
||||
# Arch Linux
|
||||
pacman -Syu ipython2
|
||||
|
||||
# RHEL/CentOS (via EPEL)
|
||||
yum install python-ipython
|
||||
|
||||
|
||||
Now, in the troubling python module, add the following line at a location where
|
||||
the debugger should be started:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
test = 'test123'
|
||||
import IPython; IPython.embed_kernel()
|
||||
|
||||
After running a Salt command that hits that line, the following will show up in
|
||||
the log file:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
[CRITICAL] To connect another client to this kernel, use:
|
||||
[IPKernelApp] --existing kernel-31271.json
|
||||
|
||||
Now on the system that invoked ``embed_kernel``, run the following command from
|
||||
a shell:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# NOTE: use ipython2 instead of ipython for Arch Linux
|
||||
ipython console --existing
|
||||
|
||||
This provides a console that has access to all the vars and functions, and even
|
||||
supports tab-completion.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
print(test)
|
||||
test123
|
||||
|
||||
To exit IPython and continue running Salt, press ``Ctrl-d`` to logout.
|
||||
|
||||
|
||||
State Modules
|
||||
=============
|
||||
|
||||
|
@ -243,6 +195,8 @@ function to execute. The default system outputter is the ``nested`` module.
|
|||
Pillar
|
||||
======
|
||||
|
||||
See also: :ref:`External Pillars <external-pillars>`
|
||||
|
||||
Used to define optional external pillar systems. The pillar generated via
|
||||
the filesystem pillar is passed into external pillars. This is commonly used
|
||||
as a bridge to database data for pillar, but is also the backend to the libvirt
|
||||
|
|
Loading…
Add table
Reference in a new issue