opts.rst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. .. _opts:
  2. ====================
  3. Salt opts dictionary
  4. ====================
  5. It is very common in the Salt codebase to see `opts` referred to in a number of
  6. contexts.
  7. For example, it can be seen as `__opts__` in certain cases, or simply as `opts`
  8. as an argument to a function in others.
  9. Simply put, this data structure is a dictionary of Salt's runtime configuration
  10. information that's passed around in order for functions to know how Salt is configured.
  11. When writing Python code to use specific parts of Salt, it may become necessary
  12. to initialize a copy of `opts` from scratch in order to have it available for a
  13. given function.
  14. To do so, use the utility functions available in `salt.config`.
  15. As an example, here is how one might generate and print an options dictionary
  16. for a minion instance:
  17. .. code-block:: python
  18. import salt.config
  19. opts = salt.config.minion_config("/etc/salt/minion")
  20. print(opts)
  21. To generate and display `opts` for a master, the process is similar:
  22. .. code-block:: python
  23. import salt.config
  24. opts = salt.config.master_config("/etc/salt/master")
  25. print(opts)