2015-05-13 05:41:02 +00:00
|
|
|
.. _opts:
|
|
|
|
|
|
|
|
====================
|
|
|
|
Salt opts dictionary
|
|
|
|
====================
|
|
|
|
|
|
|
|
It is very common in the Salt codebase to see `opts` referred to in a number of
|
|
|
|
contexts.
|
|
|
|
|
2015-05-13 15:04:26 +00:00
|
|
|
For example, it can be seen as `__opts__` in certain cases, or simply as `opts`
|
2015-05-13 05:41:02 +00:00
|
|
|
as an argument to a function in others.
|
|
|
|
|
2015-05-13 15:04:26 +00:00
|
|
|
Simply put, this data structure is a dictionary of Salt's runtime configuration
|
|
|
|
information that's passed around in order for functions to know how Salt is configured.
|
2015-05-13 05:41:02 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2015-05-13 15:04:26 +00:00
|
|
|
To do so, use the utility functions available in `salt.config`.
|
2015-05-13 05:41:02 +00:00
|
|
|
|
|
|
|
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)
|