Add documentation about opts generation

This commit is contained in:
Mike Place 2015-05-12 23:41:02 -06:00
parent c061bded54
commit 1432077bd8

View File

@ -0,0 +1,38 @@
.. _opts:
====================
Salt opts dictionary
====================
It is very common in the Salt codebase to see `opts` referred to in a number of
contexts.
For example, it can be seen as `__opts__` in certain cases, or simple as `opts`
as an argument to a function in others.
Simply put, this data structure is simply a dictionary of Salt's runtime
configuration information that's passed around in order for functions to
know how Salt is configured.
When writing Python code to use specific parts of Salt, it may become necessary
to initialize a copy of `opts` from scratch in order to have it available for a
given function.
To do so, use the utility functions available in `salt.config` to do so.
As an example, here is how one might generate and print an options dictionary
for a minion instance:
.. code-block:: python
import salt.config
opts = salt.config.minion_config('/etc/salt/minion')
print(opts)
To generate and display `opts` for a master, the process is similar:
.. code-block:: python
import salt.config
opts = salt.config.master_config('/etc/salt/master')
print(opts)